1
0
Fork 0
pixelfed/app/Jobs/AvatarPipeline/CreateAvatar.php

54 lines
1.2 KiB
PHP
Raw Normal View History

2018-05-22 23:57:52 +00:00
<?php
namespace App\Jobs\AvatarPipeline;
2018-08-28 03:07:36 +00:00
use App\Avatar;
use App\Profile;
2018-05-22 23:57:52 +00:00
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
2018-08-28 03:07:36 +00:00
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
2018-05-22 23:57:52 +00:00
class CreateAvatar implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2018-05-31 22:04:15 +00:00
protected $profile;
2018-08-28 03:07:36 +00:00
2019-01-12 22:24:20 +00:00
/**
* Delete the job if its models no longer exist.
*
* @var bool
*/
public $deleteWhenMissingModels = true;
2018-05-22 23:57:52 +00:00
/**
* Create a new job instance.
*
* @return void
*/
2018-05-31 22:04:15 +00:00
public function __construct(Profile $profile)
2018-05-22 23:57:52 +00:00
{
2018-05-31 22:04:15 +00:00
$this->profile = $profile;
2018-05-22 23:57:52 +00:00
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
2018-05-31 22:04:15 +00:00
$profile = $this->profile;
$path = 'public/avatars/default.png';
2018-08-28 03:07:36 +00:00
$avatar = new Avatar();
2018-05-31 22:04:15 +00:00
$avatar->profile_id = $profile->id;
2018-05-22 23:57:52 +00:00
$avatar->media_path = $path;
$avatar->thumb_path = $path;
$avatar->change_count = 0;
$avatar->last_processed_at = \Carbon\Carbon::now();
$avatar->save();
}
}