Mi codigo del command es:
Código PHP:
<?php
namespace AppConsoleCommands;
use IlluminateConsoleCommand;
use Appm_empr;
use Appd_empr_sect;
use Appm_norm;
use Appm_sect;
class NuevaNorma extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'msg:normas';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Enviara correos electronicos de forma mensual, avisando sobre las nuevas normas del mes';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$t_sect = m_sect::select('m_sects.id', 'm_sects.no_sect')->get();
$t_empr = m_empr::select('no_empr', 'id_sect', 'em_empr')->get();
foreach($t_sect as $ts){
$t_norm = $this->getData($ts->id);
$date = date('Y-m-d');
$pdf = PDF::loadView('docs.mensaje', compact('t_norm', 'date'))
->save( 'docs/normas_'.$ts->id.'.pdf' );
}
foreach($t_empr as $te){
Mail::send('email.mensual', ['te' => $te], function($msj) use ($te){
$address = '[email protected]';//$inputs['email'];
$name = 'OISCI Global'; //$inputs['name'];
$msj->subject('Se publicaron nuevas normas este mes.');
$msj->to($te->em_empr);
$msj->attach('docs/normas_'.$te->id_sect.'.pdf');
});
}
}
public function getData($id)
{
$data = m_norm::select(
'm_tipos.ab_tipo',
'm_norms.nu_norm',
'm_norms.no_norm',
'm_norms.fe_publ_norm',
'm_norms.fe_vige_norm'
)
->join ('d_norm_sects', 'd_norm_sects.id_norm', '=', 'm_norms.id')
->join ('m_tipos', 'm_tipos.id', '=', 'm_norms.id_tipo')
->where('d_norm_sects.id_sect',$id)
->orderBy('m_norms.no_norm', 'ASC')
->get();
return $data;
}
}
Código PHP:
<?php
namespace AppConsole;
use IlluminateConsoleSchedulingSchedule;
use IlluminateFoundationConsoleKernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
// Commands\Inspire::class,
'App\Console\Commands\NuevaNorma'
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('msg:normas')
->cron('0,15,30,45 * * * *');
}
}
Código:
He probado con los 4 cron y ninguno me funciona./usr/local/bin/php -q /legalvl/artisan schedule:run 1>> /dev/null 2>&1 php /home/fymgestion/legalvl/artisan schedule:run >> /dev/null 2>&1 php -q /legalvl/artisan schedule:run 1>> /dev/null 2>&1 /usr/local/bin/php -q /home/fymgestion/legalvl/artisan schedule:run 1>> /dev/null 2>&1
Alguna idea?