Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Console\Commands;
- use App\Models\Cron;
- use App\Models\Market;
- use App\Models\Seo;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Mail;
- use App\Models\Barco;
- use App\Models\Imovel;
- class AgendamentoBarco extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'agendamento:barco';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Agendamento Barco';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $cron = Cron::where('data', Carbon::now()->toDateString())->where('status', 1)->first();
- if ($cron) {
- if (isset($cron->barco) && !is_null($cron->barco)) {
- $barco = $cron->barco;
- if ($barco->id > 0) {
- /*
- Mail::send('painel.campanha.barco', compact('barco'), function ($message) use ($barco) {
- $seo = Seo::first();
- //$market = Market::all()->pluck('email')->toArray();
- $market = ['rafadinix@gmail.com'];
- //$market = 'catracacelo@gmail.com';
- $email = ['marcelo@ciaboat.com.br'];
- $message->from('marcelo@ciaboat.com.br', $seo->title)->subject("Oportunidade " . $barco->modelo);
- $message->bcc($market);
- });
- */
- ob_start();
- //$barco = $this->barco->find($id);
- $url = "http://www.ciaboat.com.br/embarcacao_mail/$barco->slug";
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => false,
- CURLOPT_HEADER => false,
- CURLOPT_SSL_VERIFYPEER => false
- ));
- $result=curl_exec ($ch);
- echo $result;
- curl_close ($ch);
- $body = ob_get_contents();
- ob_end_clean();
- $url = 'https://api.elasticemail.com/v2/email/send';
- try{
- $seo = Seo::find(1);
- //$market = Market::all()->pluck('email')->toArray();
- $market = ['rafadinix@gmail.com','catracacelo@gmail.com'];
- $post = array(
- 'from' => 'marcelo@ciaboat.com.br',
- 'fromName' => $seo->title,
- 'apikey' => 'a7be9bd0-671b-400b-b0ae-36450abbb5cf',
- 'subject' => "Oportunidade $barco->modelo",
- 'msgTo' => 'marcelo@ciaboat.com.br',
- 'msgBcc' => implode(";",$market),
- 'bodyHtml' => $body,
- 'bodyText' => 'Text Body',
- 'isTransactional' => false);
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $post,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_HEADER => false,
- CURLOPT_SSL_VERIFYPEER => false
- ));
- $result=curl_exec ($ch);
- //echo $result;
- curl_close ($ch);
- }
- catch(Exception $ex){
- // echo $ex->getMessage();
- }
- $cron->update(['status' => 2]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement