Ejemplo n.º 1
0
 /**
  * Show the application dashboard.
  *
  * @param $id
  * @param MessagesRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store($id, MessagesRequest $request)
 {
     try {
         if (count($request->get('messages'))) {
             foreach ($request->get('messages') as $locale => $text) {
                 if ($text) {
                     $message = Message::whereTranslateId($id)->whereLocaleId($locale)->first();
                     if (!$message) {
                         $message = new Message();
                         $message->locale_id = $locale;
                         $message->translate_id = $id;
                     }
                     $message->message = $text;
                     $message->save();
                 }
             }
         }
         $request->session()->flash('message', 'Translates was successful!');
         $request->session()->flash('alert', 'success');
     } catch (\Exception $e) {
         $request->session()->flash('message', 'Translates error!');
         $request->session()->flash('alert', 'danger');
     }
     return redirect('/translates');
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Message $newmessage, MessagesRequest $requests)
 {
     // return $requests->all();
     // $data = ['subject'=>'Some Subject'];
     $sent = Mail::send('emails.website', ['data' => $requests->all()], function ($message) use($requests) {
         $message->from($requests->get('email'), $requests->get('name'))->to('*****@*****.**', 'Carlos Perez')->cc('*****@*****.**', 'Yismen Jorge')->subject(ucwords($requests->get('subject')));
     });
     $newmessage = $newmessage->create($requests->all());
     if ($requests->ajax()) {
         return response()->json(['success' => 1, 'message' => $newmessage]);
     }
     return redirect()->route('site.route')->withSuccess("Your message has been received and we will get in touch with you shortly!");
 }