public function link($id) { $bookmark = Bookmark::findOrFail($id); $bookmark->hit_cnt = $bookmark->hit_cnt + 1; $bookmark->save(); return redirect($bookmark->url); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $bookmark = Bookmark::findOrFail($id); $this->authorize('update-destroy', $bookmark); $bookmark->delete(); return $bookmark; }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $bookmark = Bookmark::findOrFail($id); $bookmark->url = $request->input('url'); $bookmark->title = $request->input('title'); $bookmark->description = $request->input('description'); $bookmark->public = $request->input('public'); $bookmark->pin = $request->input('pin'); $bookmark->save(); Tag::where('bookmark_id', $id)->delete(); foreach ($request->input('tags') as $keyword) { $tag = new Tag(['tag' => $keyword]); $bookmark->tags()->save($tag); } $this->dispatch(new TakeSnapshotCommand($bookmark)); return response()->json($bookmark); }
$bookmark->name = $request->name; $bookmark->url = $request->url; $bookmark->description = trim($request->description); $bookmark->save(); return redirect('/home'); } else { return redirect('/'); } }); /** * DELETE /bookmark/{id} * Delete the bookmark at the associated {id} */ Route::delete('/bookmark/{id}', function ($id) { if (Auth::check()) { $bookmark = Bookmark::findOrFail($id); $bookmark->categories()->detach(); $bookmark->delete(); return redirect()->back(); } else { return redirect('/'); } }); /** * POST /send-message * Send a message to another user */ Route::post('/send-message', function (Request $request) { if (Auth::check()) { $target_user = User::findOrFail($request->user_id); $notify = new Notification();
public function postEdit(Request $request) { $userID = Auth::user()->id; //Make sure title and tags are provided $validator = $this->editValidator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $tags = explode(",", $request->tags); try { //Find the bookmark with ID=$id $bookmark = Bookmark::findOrFail($request->id); if ($bookmark->owner_id != $userID) { return "This is not your bookmark"; } //Update the bookmark's title $bookmark->title = $request->page_title; $bookmark->colour = $request->colour; $bookmark->save(); //Now create a new tag object for each of the tags //Only if it doesn't already exist in tags foreach ($tags as $tag_name) { // Retrieve the tag by the attributes, or instantiate a new instance... $tag = Tag::firstOrNew(array('tag_name' => $tag_name)); $tag->save(); $bookmarkTag = BookmarkTag::firstOrNew(array('bookmark_id' => $bookmark->bookmark_id, 'tag_id' => $tag->tag_id)); $bookmarkTag->save(); } } catch (ModelNotFoundException $e) { return "Bookmark not found: " . $e->getMessage(); } return redirect($this->bookmarksPath); }
public function show($id) { $bookmark = Bookmark::findOrFail($id); return view('bookmarks.show', compact('bookmark')); }