Skip to content

Commit 0fdf277

Browse files
author
Lupacescu Eduard
authored
Refresh command (#129)
1 parent a2b00d6 commit 0fdf277

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/Commands/Refresh.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Binaryk\LaravelRestify\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class Refresh extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'restify:refresh';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Clear all laravel caches (routes, cache, config and view)';
22+
23+
/**
24+
* Execute the console command.
25+
*
26+
* @return mixed
27+
*/
28+
public function handle()
29+
{
30+
$this->call('route:cache');
31+
$this->call('cache:clear');
32+
$this->call('config:cache');
33+
$this->call('view:clear');
34+
$this->call('optimize');
35+
}
36+
}

src/LaravelRestifyServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Binaryk\LaravelRestify\Commands\BaseRepositoryCommand;
66
use Binaryk\LaravelRestify\Commands\CheckPassport;
77
use Binaryk\LaravelRestify\Commands\PolicyCommand;
8+
use Binaryk\LaravelRestify\Commands\Refresh;
89
use Binaryk\LaravelRestify\Commands\RepositoryCommand;
910
use Binaryk\LaravelRestify\Commands\SetupCommand;
1011
use Binaryk\LaravelRestify\Http\Middleware\RestifyInjector;
@@ -24,6 +25,7 @@ public function boot()
2425
SetupCommand::class,
2526
PolicyCommand::class,
2627
BaseRepositoryCommand::class,
28+
Refresh::class,
2729
]);
2830
$this->registerPublishing();
2931

src/Repositories/Repository.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function model()
6262
*/
6363
public static function uriKey()
6464
{
65+
if (property_exists(static::class, 'uriKey') && is_string(static::$uriKey)) {
66+
return static::$uriKey;
67+
}
68+
6569
return Str::plural(Str::kebab(class_basename(get_called_class())));
6670
}
6771

0 commit comments

Comments
 (0)