$name, 'carbon'=>$carbon ]; if($name=="apply_student_proposal"){ $data['teacher'] = User::find($req->id); $data['student'] = User::find($user->id); $data['proposal']= Proposal::where('student_id',$user->id)->get(); }elseif($name=="view_apply_proposal"){ $data['std_proposal'] =StudentProposal::find($req->id); }elseif($name=="add_destination"){ } else $name='default'; return view("modal_pages.{$name}", $data); } public function post(Request $req, $name){ $user=\Auth::user(); $carbon=new \Carbon\Carbon; if($name=='apply_student_proposal'){ $validator=\Validator::make($req->all(), [ 'proposal_id'=>'required', 'startdate'=>'required', 'startmonth'=>'required', ]); if($validator->fails()){ $errors=$validator->errors()->all(); return response(['msg'=>$errors[0]], 422); } $student_proposal =new StudentProposal; $student_proposal->student_id =$req->student_id; $student_proposal->teacher_id =$req->teacher_id; $student_proposal->proposal_id =$req->proposal_id; $student_proposal->start_year =$req->startdate; $student_proposal->start_month =$req->startmonth; $student_proposal->created_by =$user->id; $student_proposal->student_apply_ref =studentRefNoGenerate(); $student_proposal->save(); $user =User::find($req->id); if($user){ $data['name'] = $user->first_name.' '.$user->last_name; $user_mail =$user->email; $from = 'test@mail.com'; Mail::send('email.send_apply_student_teacher_email',$data, function ($message) use ($user_mail,$from) { $message->from($from); $message->to($user_mail)->subject('New Email Send to you'); }); } return response(['msg'=>'Proposal send successfully.']); } return response(['msg'=>'No name argument found.'], 403); } }