/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function getStore($id = null) { if ($id) { $location = Location::find($id); if (!$location) { return response()->json(JSend::fail(['Data not found'])->encode()); } } else { $location = new Location(); } // $location->fill(Input::all()); if ($location->save()) { return response()->json(JSend::success($location->toArray())->encode()); } else { return response()->json(JSend::fail($location->getErrors()->toArray())->encode()); } }