Skip to content

Instantly share code, notes, and snippets.

@New0
Last active September 9, 2020 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save New0/a0077f2ec34706ad59d6519724151021 to your computer and use it in GitHub Desktop.
Save New0/a0077f2ec34706ad59d6519724151021 to your computer and use it in GitHub Desktop.
Query recent messages
<?php
namespace App\Console\Commands;
use App\Message;
use Carbon\Carbon;
use Illuminate\Console\Command;
class RecentlyUsedAccounts extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'account:recent';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Get recently used accounts';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$headers = [
'id',
'account',
'layout',
'pdf',
'pdf_layout',
'to',
'reply',
'cc',
'bcc',
'content',
'subject',
'hash',
'opened',
'clicked',
'spammed',
'entry_data',
'local_id',
'attachments',
'spam_detected'
];
$accounts = Message::all( $headers )->where( 'created_at', '<=', Carbon::now()->subMonth()->month )->toArray();
$this->table($headers, $accounts);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment