1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Providers; |
4
|
|
|
|
5
|
|
|
use App\Model\Update\BarNotification; |
6
|
|
|
use Illuminate\Queue\Events\JobFailed; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
use Queue; |
9
|
|
|
use View; |
10
|
|
|
|
11
|
|
|
class AppServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Register any application services. |
15
|
|
|
* |
16
|
|
|
* This service provider is a great spot to register your various container |
17
|
|
|
* bindings with the application. As you can see, we are registering our |
18
|
|
|
* "Registrar" implementation here. You can add your own bindings too! |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function register() |
23
|
|
|
{ |
24
|
|
|
$this->app->bind('Illuminate\Contracts\Auth\Registrar'); |
25
|
|
|
require_once __DIR__.'/../Http/helpers.php'; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function boot() |
29
|
|
|
{ |
30
|
|
|
Queue::failing(function (JobFailed $event) { |
31
|
|
|
loging('Failed Job - '.$event->connectionName, json_encode($event->data)); |
32
|
|
|
$failedid = $event->failedId; |
|
|
|
|
33
|
|
|
//\Artisan::call('queue:retry',['id'=>[$failedid]]); |
|
|
|
|
34
|
|
|
}); |
35
|
|
|
// Please note the different namespace |
36
|
|
|
// and please add a \ in front of your classes in the global namespace |
37
|
|
|
\Event::listen('cron.collectJobs', function () { |
38
|
|
|
\Cron::add('example1', '* * * * *', function () { |
39
|
|
|
$this->index(); |
|
|
|
|
40
|
|
|
|
41
|
|
|
return 'No'; |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
\Cron::add('example2', '*/2 * * * *', function () { |
45
|
|
|
// Do some crazy things successfully every two minute |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
\Cron::add('disabled job', '0 * * * *', function () { |
49
|
|
|
// Do some crazy things successfully every hour |
50
|
|
|
}, false); |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
$this->composer(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function composer() |
57
|
|
|
{ |
58
|
|
|
\View::composer('themes.default1.update.notification', function () { |
59
|
|
|
$notification = new BarNotification(); |
60
|
|
|
$not = [ |
61
|
|
|
'notification' => $notification->where('value', '!=', '')->get(), |
|
|
|
|
62
|
|
|
]; |
63
|
|
|
view()->share($not); |
|
|
|
|
64
|
|
|
}); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.