Bookmark::paginate(20), ] ); } /** * Show the form for creating a new resource. */ public function create() { // } /** * Store a newly created resource in storage. */ public function store(Request $request) { // } /** * Display the specified resource. */ public function show(Bookmark $bookmark) { return view( 'bookmarks.show', [ 'bookmark' => $bookmark, ] ); } /** * Show the form for editing the specified resource. */ public function edit(Bookmark $bookmark) { return view( 'bookmarks.edit', [ 'edit' => true, 'bookmark' => $bookmark, ] ); } /** * Update the specified resource in storage. */ public function update(Request $request, Bookmark $bookmark) { $bookmark->title = $request->post('title'); $bookmark->description = $request->post('description', ''); $bookmark->href = $request->post('href'); $bookmark->save(); $tags_input = trim($request->post('tags', '')); $tags_input = preg_split('/\s+/', $tags_input); $tags = []; foreach ($tags_input as $tag_input) { $tag = Tag::firstOrCreate(['name' => $tag_input]); $tags[$tag->id] = true; } $bookmark->tags()->sync(array_keys($tags)); return redirect()->action( [self::class, "show"], [ "bookmark" => $bookmark, ] ); } /** * Remove the specified resource from storage. */ public function destroy(string $id) { // } }