mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-05-07 20:32:26 +00:00
46 lines
987 B
PHP
46 lines
987 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Project;
|
|
use Exception;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Events\ShouldDispatchAfterCommit;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class RecalculateSpentTimeForProject implements ShouldDispatchAfterCommit, ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
public Project $project;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct(Project $project)
|
|
{
|
|
$this->project = $project;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @throws Exception
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$this->project->setComputedAttributeValue('spent_time');
|
|
if ($this->project->isDirty()) {
|
|
$this->project->save();
|
|
}
|
|
}
|
|
}
|