I have created a cron job in the 'commands' files. and I want to get the id of the user using Auth::user()->id but I am getting the error. Where am I missing?
My error:
Trying to get property 'id' of non-object
My controller
use Illuminate\Support\Facades\Auth;
protected $signature = 'orders:minute';
public function handle()
{
$id = Auth::user()->id;
}
Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('orders:minute')
->everyMinute();
}