/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { try { $this->service->destroy($id); return response('', 204); } catch (\Exception $e) { return Response::json(["error" => true, "message" => $e->getMessage()], 400); } }
public function update(Request $request) { if (!$this->isUnique($request->name)) { return Response::json("This ingredient already exists", 400); exit; } $recipe = Ingredient::find($request->id); $ingredient->name = $request->name; $ingredient->quantity = $request->quantity; $ingredient->measure = $request->measure; $ingredient->save(); echo json_encode(true); exit; }
public function getToken() { return Response::json(['token' => csrf_token()]); }
/** * DELETE deleting data tag softly * @return Response (json) */ public function destroy($tagID) { $this->threads->delete($tagID); return Response::json(['errors' => false, 'message' => trans('forum.tag-success-delete')]); }
/** * * @return mixed */ public function index() { $data = ['data' => [['engine' => 'Trident', 'browser' => 'Internet Explorer 4.0', 'platform' => 'Win 95+', 'version' => '4', 'grade' => 'X'], ['engine' => 'Trident', 'browser' => 'Internet Explorer 5.0', 'platform' => 'Win 95+', 'version' => '5', 'grade' => 'C']]]; //return View::make('backend::index'); return Response::json($data); }
/** * Accepts an SNS message to containing the video duration * * @param Request $request * * @return mixed Json containing the success of the SNS values being stored */ public function anyCompletedtranscode(Request $request) { $decodedRequestContent = json_decode(json_decode($request->getContent(), true)['Message'], true); $video_duration = $decodedRequestContent['outputs'][0]['duration']; $thumnail_count = floor($video_duration / env('THUMBS_MADE_FRAMERATE')); $video_timecode = substr($decodedRequestContent['outputs'][0]['key'], 0, -5); $video = App\Video::where('timecode', $video_timecode)->first(); $video->thumbnail_count = (int) $thumnail_count; $video->duration_seconds = (int) $video_duration; $success = $video->save(); return Response::json(['success' => $success], 200); }
/** * 响应实例 */ public function actionResponse() { $data = array('name' => 'ken', 'age' => '32'); echo Response::json($data); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { if (!$request->body or !$request->user_id) { return Response::json(['error' => ['message' => 'Please Provide Both body and user_id']], 422); } $joke = Joke::find($id); $joke->body = $request->body; $joke->user_id = $request->user_id; $joke->save(); return Response::json(['message' => 'Joke Updated Succesfully']); }
use Illuminate\Http\Request; use Illuminate\Http\Response; Route::get('/', function () { return view('welcome'); }); Route::post('/signup', function () { $credentials = Input::only('email', 'password'); $password = Hash::make($credentials['password']); $credentials['password'] = $password; try { $user = User::create($credentials); } catch (Exception $e) { return Response::json(['error' => 'User already exists.'], response::HTTP_CONFLICT); } $token = JWTAuth::fromUser($user); return response()->json(compact('token')); }); Route::post('/signin', function () { $credentials = Input::only('email', 'password'); //dd($credentials); // $token = JWTAuth::attempt($credentials); if (!($token = JWTAuth::attempt($credentials))) { return response()->json(false, response::HTTP_UNAUTHORIZED); } return response()->json(compact('token')); }); Route::get('/restricted', ['before' => 'jwt-auth', function () { $token = JWTAuth::getToken(); $user = JWTAuth::toUser($token); return Response::json(['data' => ['email' => $user->email, 'registered_at' => $user->created_at->toDateTimeString()]]); }]);
/** * Update the specified resource in storage. * * @param MeetingRequest $request * @param int $meetingId * @param int $groupId * @return mixed */ public function update(MeetingRequest $request, $groupId, $meetingId) { $group = Group::findOrFail($groupId); $this->authorize($group); $meeting = Meeting::findOrFail($meetingId); $this->authorize($meeting); $input = $request->all(); //the planner cannot modify the duration of a planed meeting if ($meeting->start_time != NULL && $meeting->duration != $input['duration']) { return Response::json(['error' => 'the meeting is already planned, you cannot change the duration'], 422); } $meeting->update($input); return $meeting; }