%PDF- %PDF-
Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/app/Console/Commands/ |
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/app/Console/Commands/PruneMessages.php |
<?php namespace App\Console\Commands; use App\Models\Message; use Carbon\Carbon; use Illuminate\Console\Command; class PruneMessages extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'messages:prune'; /** * The console command description. * * @var string */ protected $description = 'Prune older messages'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $messages = Message::orderBy('created_at', 'desc') ->where('created_at', '<=', Carbon::now()->subMonth(3)) ->get(); foreach($messages as $message) { $message->delete(); } } }