我正在使用laravel 5.5,我想安排一项任务,我尝试使用以下代码
protected function schedule(Schedule $schedule)
{
$user_id = Auth::user()->id;
$data = MenterRequest::where('menter_subscriber_id','=',$user_id)->first();
$sentTime = $data->created_at;
$currentTime = Carbon::now();
$diff_in_hours = $sentTime->diffInHours($currentTime);
if($diff_in_hours >=75)
{
$schedule->call(function () {
DB::table('menter_requests')->where('menter_subscriber_id','=',$user_id)->delete();
})->everyMinute();
}
}
如果尝试获取身份验证用户ID 尝试获取非对象属性错误,则用户已经过身份验证或已登录。