After watching some videos on laracasts and googling the whole day, I still cannot figure this out. I am trying to learn how to use commands in laravel, and after creating a command, it all works except for the fact that I cannot reference a model from within the command. When trying to use the below, I get an error saying "Undefined namespace App".
public function handle()
{
$appointment = new App\Appointment;
}
What I am basically trying to achieve is, send daily emails using the scheduler and commands, to myself. So I need to grab the upcoming appointments for each day, that is why I need to be able to use my Appointment
model.
Or someone can tell me that what I am trying to achieve is not the way to go and I should perform this task somehow else?
Try this:
$appointment = new \App\Appointment;
Note the backslash in front of the namespace. This way you're referencing it relative to the global namespace instead of relative to your local namespace.
This is assuming you're using a custom namespace in your command class.