Exemple #1
0
 /**
  * Inserts new entry into Client Table and 
  * checks for validation on form submission
  * Authorization is checked for privilages
  * 
  * @param  	CreateClientRequest $request
  * @return 	Response
  */
 public function store(ClientRequest $request)
 {
     $input = $request->all();
     $client = Client::create($input);
     $program = Program::where('id', '=', $request->input('programs'))->first();
     $agent = Auth::user();
     $client->program()->associate($program);
     $client->agent()->associate($agent);
     $client->save();
     $temp = Temp::where('fname', '=', $request->fname)->where('lname', '=', $request->lname)->first();
     if ($temp != null) {
         $temp->delete();
     }
     $meal = new Meal();
     $meal->date_fed = date('Y-m-d');
     $meal->client()->associate($client);
     $meal->breakfast = 0;
     $meal->lunch = 0;
     $meal->dinner = 0;
     $meal->save();
     return redirect('client');
 }