diff --git a/src/Commands/Refresh.php b/src/Commands/Refresh.php new file mode 100644 index 000000000..d1619ba4e --- /dev/null +++ b/src/Commands/Refresh.php @@ -0,0 +1,36 @@ +call('route:cache'); + $this->call('cache:clear'); + $this->call('config:cache'); + $this->call('view:clear'); + $this->call('optimize'); + } +} diff --git a/src/LaravelRestifyServiceProvider.php b/src/LaravelRestifyServiceProvider.php index c766f9618..799b73214 100644 --- a/src/LaravelRestifyServiceProvider.php +++ b/src/LaravelRestifyServiceProvider.php @@ -5,6 +5,7 @@ use Binaryk\LaravelRestify\Commands\BaseRepositoryCommand; use Binaryk\LaravelRestify\Commands\CheckPassport; use Binaryk\LaravelRestify\Commands\PolicyCommand; +use Binaryk\LaravelRestify\Commands\Refresh; use Binaryk\LaravelRestify\Commands\RepositoryCommand; use Binaryk\LaravelRestify\Commands\SetupCommand; use Binaryk\LaravelRestify\Http\Middleware\RestifyInjector; @@ -24,6 +25,7 @@ public function boot() SetupCommand::class, PolicyCommand::class, BaseRepositoryCommand::class, + Refresh::class, ]); $this->registerPublishing(); diff --git a/src/Repositories/Repository.php b/src/Repositories/Repository.php index 123b5c1fa..e1f1d1185 100644 --- a/src/Repositories/Repository.php +++ b/src/Repositories/Repository.php @@ -62,6 +62,10 @@ public function model() */ public static function uriKey() { + if (property_exists(static::class, 'uriKey') && is_string(static::$uriKey)) { + return static::$uriKey; + } + return Str::plural(Str::kebab(class_basename(get_called_class()))); }