Advertisement
Guest User

Untitled

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