getFolders(); $props = $this->getProps(); $email = "mahabat@turkmentv.gov.tm"; return view('web.bukjalar')->with([ 'title'=>'Mahabat Nyrhnama bukjalary', 'keywords'=>'', 'meta_description'=>'', 'folders'=> $folders, 'props'=> $props, 'email' => $email ]); } public function getFolders(){ $allFolders = Folder::all(); return $allFolders; } public function getProps(){ $allProps = PropertyType::all(); return $allProps; } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //Mahri001@ qazwsx12 try{ $datas = $request->except('_token'); $time='Bukjada görkezizlen wagtlar!'; //dd($datas); $datas = html_entity_decode($datas['choices']); $data=json_decode($datas,true); $bukjaOrder=new BukjaOrder(); foreach ($data as $val){ if (isset($val['customer'])){ $customer=$val['customer']; $customer_name=$customer['name']; $customer_email=$customer['email']; $customer_phone=$customer['phone']; $customer_notes=$customer['notes']; $bukjaOrder->customer_name=$customer_name; $bukjaOrder->customer_email=$customer_email; $bukjaOrder->customer_phone=$customer_phone; $bukjaOrder->customer_notes=$customer_notes; } } foreach ($data as $val){ if(isset($val['id'])){ $bukjaOrder=new BukjaOrder(); $bukjaOrder->customer_name=$customer_name; $bukjaOrder->customer_email=$customer_email; $bukjaOrder->customer_phone=$customer_phone; $bukjaOrder->customer_notes=$customer_notes; $order_id = $val['id']; $second=$val['second']; $folder_id=$val['folder_id']; $folder_name=$val['folder_name']; $day=$val['day']; $time=$val['time']; $total=$val['total']; $folder=Folder::find($folder_id); $order_prop=$folder->property->title; $bukjaOrder->order_id=$order_id; $bukjaOrder->folder_id=$folder_id; $bukjaOrder->folder_name=$folder_name; $bukjaOrder->second=$second; $bukjaOrder->day=$day; $bukjaOrder->time=$time; $bukjaOrder->total=$total; $bukjaOrder->order_prop=$order_prop; $bukjaOrder->save(); $this->sendToMail($bukjaOrder); } } return $bukjaOrder; } catch(\Exception $e){ return $e->getMessage(); } } /* Send order to mail "mahabat@turkmentv.gov.tm" */ public function sendToMail($bukjaOrder){ $data = array( 'id' => utf8_encode($bukjaOrder->id), 'created_at' => $bukjaOrder->created_at, 'folder_name' => $bukjaOrder->folder_name, 'second' => $bukjaOrder->second, 'day' => $bukjaOrder->day, 'time' => $bukjaOrder->time, 'total' =>$bukjaOrder->total, 'order_prop' => $bukjaOrder->order_prop, 'customer_name' => $bukjaOrder->customer_name, 'customer_email' => $bukjaOrder->customer_email, 'customer_phone' => $bukjaOrder->customer_phone, 'customer_notes' => $bukjaOrder->customer_notes, ); Mail::send('email_temp_folder_orders', [ 'data' => $data ], function ($message){ $message->to('admin@turkmentv.gov.tm'); $message->subject('Mahabat Sargydy'); }); return response()->json(['message'=>'success'],201); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }