Sure @bobbybouwmann
In console/commands/dailyupdate.php
class dailyupdate extends Command
{
protected $signature = 'dailyupdates';
public function __construct()
{
parent::__construct();
}
public function fire()
{
$this->info('Daily Updates sent successfully');
}
public function handle()
{
$data['popular'] = Fest::orderBy('fest_popular_order', 'ASC')->where('status', 1)->whereNotNull('fest_popular_order')->take(3)->get();
$users = User::where('status', 1)->get();
if (isset($users)) {
foreach ($users as $user) {
\Mail::send('mails.dailyupdate', $data, function ($message) use ($user) {
$message->from('contact@festsamachar.com', 'Fest Samachar');
$message->to($user->email_id);
$message->subject('Hi ' . $user->name . '.. Popular Fests in Fest Samachar');
});
}
}
In commands/kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('dailyupdates')
->daily();
}
My cron command in shared hosting:
php /home/festsama/public_html/livesite/live/artisan schedule:run
in laravel.log the error showing as
#0 /home/festsama/public_html/livesite/live/vendor/symfony/console/Input/ArgvInput.php(287): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/festsama/...', 287, Array)
#1 /home/festsama/public_html/livesite/live/vendor/symfony/console/Application.php(827): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array)
#2 /home/festsama/public_html/livesite/live/vendor/symfony/console/Application.php(123): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/festsama/public_html/livesite/live/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/festsama/public_html/livesite/live/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))