Browse Source

Add long run job and notification after finish

pull/1/head
Nafies Luthfi 5 years ago
parent
commit
b094e3012b
  1. 26
      app/Jobs/LongRunJob.php
  2. 1
      public/js/plugins/noty.js
  3. 12
      resources/views/welcome.blade.php
  4. 2
      routes/web.php

26
app/Jobs/LongRunJob.php

@ -0,0 +1,26 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class LongRunJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
sleep(3);
app('session')->flash('flash_notification.message', 'Long run job done.');
}
}

1
public/js/plugins/noty.js
File diff suppressed because it is too large
View File

12
resources/views/welcome.blade.php

@ -97,4 +97,16 @@
</div> </div>
</div> </div>
</body> </body>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="{{ asset('js/plugins/noty.js') }}"></script>
@if (Session::has('flash_notification.message'))
<script>
noty({
type: 'success',
layout: 'bottomRight',
text: '{{ Session::get('flash_notification.message') }}',
timeout: 5000
});
</script>
@endif
</html> </html>

2
routes/web.php

@ -1,5 +1,6 @@
<?php <?php
use App\Jobs\LongRunJob;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
/* /*
@ -14,5 +15,6 @@ use Illuminate\Support\Facades\Route;
*/ */
Route::get('/', function () { Route::get('/', function () {
dispatch(new LongRunJob());
return view('welcome'); return view('welcome');
}); });
Loading…
Cancel
Save