55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use App\Models\User;
|
|
use App\Models\NotificationUser;
|
|
use App\Models\NotificationMaster;
|
|
|
|
|
|
class MoodOMeterNotification extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'mood-o-meter:send-daily';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Daily Mood O Meter Reminder';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$user = User::get();
|
|
|
|
// NotificationMaster::create[]
|
|
$notification_master = new NotificationMaster;
|
|
$notification_master->title = "Send Your Daily Mood O Meter";
|
|
$notification_master->messages = "Mood-O-Meter";
|
|
$notification_master->save();
|
|
|
|
$notification_id = $notification_master->id;
|
|
|
|
foreach ($user as $user_data){
|
|
|
|
$notification_user = new NotificationUser;
|
|
$notification_user->notification_id = $notification_id;
|
|
$notification_user->user_id = $user_data->id;
|
|
$notification_user->save();
|
|
}
|
|
|
|
$this->info('Mood-O-Meter Notification Send succefully');
|
|
}
|
|
}
|