格式化代码
This commit is contained in:
parent
2c275c08cf
commit
f6bc106774
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Module\WorkOrder;
|
namespace App\Jobs\Module\WorkOrder;
|
||||||
|
|
||||||
use App\Events\Users;
|
|
||||||
use App\Models\WorkOrder\WorkOrder as WorkOrderModel;
|
use App\Models\WorkOrder\WorkOrder as WorkOrderModel;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
use App\Exceptions\CommonException;
|
use App\Exceptions\CommonException;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use function auth;
|
use function auth;
|
||||||
use function broadcast;
|
use function broadcast;
|
||||||
@ -31,7 +30,7 @@ class Task extends Model
|
|||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
static::creating(function ($model) {
|
static::creating(function (self $model) {
|
||||||
// id 为 uuid
|
// id 为 uuid
|
||||||
$model->id = Uuid::uuid4()->toString();
|
$model->id = Uuid::uuid4()->toString();
|
||||||
|
|
||||||
@ -54,34 +53,30 @@ protected static function boot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$model->user_id = $model->host->user_id;
|
$model->user_id = $model->host->user_id;
|
||||||
|
|
||||||
Cache::forget('user_tasks_' . $model->user_id);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// created
|
// created
|
||||||
static::created(function ($model) {
|
static::created(function (self $model) {
|
||||||
$model->load('host');
|
$model->load('host');
|
||||||
broadcast(new Users($model->user_id, 'tasks.created', $model));
|
broadcast(new Users($model->user_id, 'tasks.created', $model));
|
||||||
});
|
});
|
||||||
|
|
||||||
// updating
|
// updating
|
||||||
static::updating(function ($model) {
|
static::updating(function (self $model) {
|
||||||
if ($model->progress == 100) {
|
if ($model->progress == 100) {
|
||||||
$model->status = 'done';
|
$model->status = 'done';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// updated and delete
|
// updated and delete
|
||||||
static::updated(function ($model) {
|
static::updated(function (self $model) {
|
||||||
// Cache::forget('user_tasks_' . $model->user_id);
|
|
||||||
|
|
||||||
$model->load('host');
|
$model->load('host');
|
||||||
broadcast(new Users($model->user_id, 'tasks.updated', $model));
|
broadcast(new Users($model->user_id, 'tasks.updated', $model));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
static::deleted(function ($model) {
|
static::deleted(function (self $model) {
|
||||||
broadcast(new Users($model->user_id, 'tasks.deleted', $model));
|
broadcast(new Users($model->user_id, 'tasks.deleted', $model));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,16 +29,6 @@ public function __construct(array|Model $message, string $type)
|
|||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function via(): array
|
|
||||||
{
|
|
||||||
return [WebChannel::class];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
* Get the array representation of the notification.
|
||||||
*
|
*
|
||||||
@ -48,4 +38,14 @@ public function toArray(): array
|
|||||||
{
|
{
|
||||||
return $this->message;
|
return $this->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via(): array
|
||||||
|
{
|
||||||
|
return [WebChannel::class];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user