first commit
This commit is contained in:
54
app/Console/Commands/MoodOMeterNotification.php
Normal file
54
app/Console/Commands/MoodOMeterNotification.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user