/**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(LocationCreateRequest $request)
 {
     $state = $request->input('state');
     if (!($existingState = State::where('id', $state)->first())) {
         $newState = new State();
         $newState->name = $state;
         $newState->save();
     }
     $locs = $request->input('lga');
     foreach ($locs as $loc) {
         $area = new Lga();
         $area->name = $loc;
         $area->state_id = $newState->id;
         $area->save();
     }
     return redirect('/admin/location')->withSuccess("Area created.");
 }
Exemplo n.º 2
0
 public function store(LocationCreateRequest $request)
 {
     Location::create($request->all());
     flash()->success(trans('location.label.name'), trans('location.message_alert.create_success'));
     return redirect('/locations');
 }