
もくじ
日付であればCarbonさん!
5分前の日時を取得したいならこれ
Carbon::now()->subMinutes(5)->toDateTimeString();
subMinutes(int 分)->toDateTimeString()
実装例
namespace App\Validators\MovieUploaderJob;
use App\Entities\MovieUploaderJobHistory;
use App\Repositories\MovieUploaderJob\MovieUploaderJobHistoryInterface;
use Illuminate\Support\Carbon;
class InExcutingValidator
{
private $i_movie_uploader_job_history;
public function __construct(
MovieUploaderJobHistoryInterface $i_movie_uploader_job_history
) {
$this->;i_movie_uploader_job_history = $i_movie_uploader_job_history;
}
public function validate($attribute, $value, $parameters, $validator)
{
$data = $validator->;getData();
$movie_uploader_job_histories = $this->;i_movie_uploader_job_history->byWhere([
['company_id', '=', $data['company_id']],
['staff_id', '=', $request['staff_id']],
['status', '>', MovieUploaderJobHistory::STATUSES['finished']],
// 5分経過している場合は前回が処理中のステータスでも無視してアップロードできるようにする
['created_at', '>', Carbon::now()->;subMinutes(5)->toDateTimeString()],
]);
return $movie_uploader_job_histories->isEmpty();
}
}

