Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aleksandertabor/2cad93e2ca299485298b51f5d004c64f to your computer and use it in GitHub Desktop.
Save aleksandertabor/2cad93e2ca299485298b51f5d004c64f to your computer and use it in GitHub Desktop.
<?php
namespace App\Jobs\Examples;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use MichaelLedin\LaravelJob\FromParameters;
class ExampleJob implements ShouldQueue, FromParameters
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(public string $videoName, public Carbon $releasedAt, public User $user)
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
dd($this->user);
// dd('Example job handle');
}
public static function fromParameters(...$parameters)
{
return new self($parameters[0], Carbon::parse($parameters[1]), User::find($parameters[2]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment