/** * Execute the job. * * @return void */ public function handle(Mailer $mailer) { $card = Card::detail($this->card_id); $person = []; /*$person['reciever_name'] = $this->reciever['name']; $person['reciever_email'] = $this->contact;*/ $person['message'] = $this->message; $contactSelect = $this->contact; /*$mailer->send(['email.card', 'email.plainText.card'] , ['card' => $card, 'person' => $person] , function($message) use ($person){ $message ->from('*****@*****.**', '中正大學電子賀卡系統') ->to($person['reciever_email'], $person['reciever_name']) ->subject('中正大學電子賀卡系統卡片通知'); });*/ foreach ($contactSelect as $contactSelects) { $contactName = strtok($contactSelects, "/"); $contactEmail = strtok("/"); if ($contactSelects != NULL) { $contactDetails = DB::table('contact')->where('email', $contactEmail)->where('user_id', Auth::user()->id)->get(); $contactExist = DB::table('contact')->where('email', $contactEmail)->where('user_id', Auth::user()->id)->count(); if (!$contactExist) { DB::table('contact')->insert(['user_id' => Auth::user()->id, 'des' => $contactName, 'email' => $contactEmail, 'classify_id' => 0, 'send_times' => 1]); $person['reciever_name'] = $contactName; } if (!$contactExist) { $person['reciever_name'] = $contactName; } else { $person['reciever_name'] = $contactDetails[0]->des; } $person['reciever_email'] = $contactEmail; $mailer->send(['email.card', 'email.plainText.card'], ['card' => $card, 'person' => $person], function ($message) use($person) { $message->from('*****@*****.**', '中正大學電子賀卡系統')->to($person['reciever_email'], $person['reciever_name'])->subject('中正大學電子賀卡系統卡片通知'); }); DB::table('mail_history')->insert(['user_id' => Auth::user()->id, 'card_id' => $this->card_id, 'reciever_name' => $person['reciever_name'], 'reciever_email' => $person['reciever_email'], 'message' => $this->message, 'created_at' => date('Y-m-d H:i:s'), 'type' => $this->type, 'status' => 'success']); } } // Log /*DB::table('mail_history') ->insert([ 'user_id' => Auth::user()->id, 'card_id' => $this->card_id, 'reciever_name' => $this->reciever['name'], 'reciever_email' => $this->reciever['email'], 'message' => $this->message, 'created_at' => date('Y-m-d H:i:s'), 'type' => $this->type, 'status' => 'success' ]);*/ }
public static function deleteChild($id) { $result = []; $current = DB::table('category')->where('id', '=', $id)->first(); $i = 0; if ($current) { $parent = $current->parent; $child = $current->child; $wait_delete = DB::table('card')->where('parent', '=', $parent)->where('child', '=', $child)->get(); for ($i = 0; $i < count($wait_delete); $i++) { Card::delete($wait_delete[$i]->id); } } $result['delete_card_counts'] = $i; $result['child'] = DB::table('category')->where('id', '=', $id)->delete(); return $result; }
public function popularCard() { $card = Card::popularDetail(); $navbar = Navbar::get(); return view('web.card')->with('navbar', $navbar)->with('fb_app_id', env('FB_client_id'))->with('card_id', $card->id)->with('card_name', $card->name)->with('card_description', $card->description)->with('author', $card->author); }
public function name() { $result = Card::name(); return $result; }