Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Console\Commands;
  4.  
  5. use App\Models\Cron;
  6. use App\Models\Seo;
  7. use Illuminate\Console\Command;
  8.  
  9. class AgendamentoBarco extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'agendamento:barco';
  17.  
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = 'Agendamento Barco';
  24.  
  25. /**
  26. * Create a new command instance.
  27. *
  28. * @return void
  29. */
  30. public function __construct()
  31. {
  32. parent::__construct();
  33. }
  34.  
  35. /**
  36. * Execute the console command.
  37. *
  38. * @return mixed
  39. */
  40. public function handle()
  41. {
  42. $cron = Cron::where('data', Carbon::now()->toDateString())->where('status', 1)->first();
  43. if ($cron) {
  44. if (isset($cron->barco) && !is_null($cron->barco)) {
  45. $barco = $cron->barco;
  46. if ($barco->id > 0) {
  47. /*
  48. Mail::send('painel.campanha.barco', compact('barco'), function ($message) use ($barco) {
  49. $seo = Seo::first();
  50. //$market = Market::all()->pluck('email')->toArray();
  51. $market = ['rafadinix@gmail.com'];
  52. //$market = 'catracacelo@gmail.com';
  53. $email = ['marcelo@ciaboat.com.br'];
  54. $message->from('marcelo@ciaboat.com.br', $seo->title)->subject("Oportunidade " . $barco->modelo);
  55. $message->bcc($market);
  56. });
  57. */
  58.  
  59.  
  60. ob_start();
  61. //$barco = $this->barco->find($id);
  62. $url = "http://www.ciaboat.com.br/embarcacao_mail/$barco->slug";
  63. $ch = curl_init();
  64. curl_setopt_array($ch, array(
  65. CURLOPT_URL => $url,
  66. CURLOPT_RETURNTRANSFER => false,
  67. CURLOPT_HEADER => false,
  68. CURLOPT_SSL_VERIFYPEER => false
  69. ));
  70. $result = curl_exec($ch);
  71. echo $result;
  72. curl_close($ch);
  73. $body = ob_get_contents();
  74. ob_end_clean();
  75.  
  76. $url = 'https://api.elasticemail.com/v2/email/send';
  77. try {
  78.  
  79. $seo = Seo::first();
  80. //$market = Market::all()->pluck('email')->toArray();
  81. $market = ['rafadinix@gmail.com', 'catracacelo@gmail.com'];
  82. $post = array(
  83. 'from' => 'marcelo@ciaboat.com.br',
  84. 'fromName' => $seo->title,
  85. 'apikey' => 'a7be9bd0-671b-400b-b0ae-36450abbb5cf',
  86. 'subject' => "Oportunidade $barco->modelo",
  87. 'msgTo' => 'marcelo@ciaboat.com.br',
  88. 'msgBcc' => implode(";", $market),
  89. 'bodyHtml' => $body,
  90. 'bodyText' => 'Text Body',
  91. 'isTransactional' => false);
  92. $ch = curl_init();
  93. curl_setopt_array($ch, array(
  94. CURLOPT_URL => $url,
  95. CURLOPT_POST => true,
  96. CURLOPT_POSTFIELDS => $post,
  97. CURLOPT_RETURNTRANSFER => true,
  98. CURLOPT_HEADER => false,
  99. CURLOPT_SSL_VERIFYPEER => false
  100. ));
  101. $result = curl_exec($ch);
  102. //echo $result;
  103. curl_close($ch);
  104. } catch (Exception $ex) {
  105. // echo $ex->getMessage();
  106. }
  107. $cron->update(['status' => 2]);
  108. }
  109. }
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement