Issues (54)

src/Console/ClearCommand.php (1 issue)

1
<?php
2
3
namespace PhpCollective\MenuMaker\Console;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\Cache;
7
use PhpCollective\MenuMaker\Jobs\RemoveUserMenuCache;
8
9
class ClearCommand extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'menu:clear';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Clear all cache from Menu Maker';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return void
29
     */
30
    public function handle()
31
    {
32
        Cache::forget('routes');
33
        Cache::forget('excluded-action-list');
34
        Cache::forget('route-actions');
35
        Cache::forget('public-routes');
36
        $model = resolve('userModel');
37
        $model->chunk(100, function ($users) {
0 ignored issues
show
The method chunk() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $model->/** @scrutinizer ignore-call */ 
38
                chunk(100, function ($users) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
            $users->each(function ($user) {
39
                RemoveUserMenuCache::dispatch($user);
40
            });
41
        });
42
43
        $this->info('Menu caches cleared!');
44
    }
45
}
46