2024-05-24 23:48:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Bookmark;
|
2024-05-29 21:07:23 +00:00
|
|
|
use App\Models\Tag;
|
2024-05-24 23:48:23 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class BookmarkController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2024-05-25 12:47:48 +00:00
|
|
|
return view(
|
|
|
|
'bookmarks.index', [
|
|
|
|
'bookmarks' => Bookmark::paginate(20),
|
|
|
|
]
|
|
|
|
);
|
2024-05-24 23:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
2024-05-30 20:55:08 +00:00
|
|
|
return view('bookmarks.edit', ['bookmark' => null]);
|
2024-05-24 23:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2024-05-30 20:55:08 +00:00
|
|
|
$bookmark = new Bookmark;
|
|
|
|
$bookmark->title = $request->post('title');
|
|
|
|
$bookmark->description = $request->post('description', '');
|
|
|
|
$bookmark->href = $request->post('href');
|
|
|
|
$bookmark->save();
|
|
|
|
|
|
|
|
$bookmark->syncTagsFromString($request->post('tags', ''));
|
|
|
|
|
|
|
|
return redirect()->action(
|
|
|
|
[self::class, "show"], [
|
|
|
|
"bookmark" => $bookmark,
|
|
|
|
]
|
|
|
|
);
|
2024-05-24 23:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*/
|
2024-05-26 13:41:28 +00:00
|
|
|
public function show(Bookmark $bookmark)
|
2024-05-24 23:48:23 +00:00
|
|
|
{
|
|
|
|
return view(
|
2024-05-25 12:47:48 +00:00
|
|
|
'bookmarks.show', [
|
2024-05-26 13:41:28 +00:00
|
|
|
'bookmark' => $bookmark,
|
2024-05-24 23:48:23 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*/
|
2024-05-26 13:41:28 +00:00
|
|
|
public function edit(Bookmark $bookmark)
|
2024-05-24 23:48:23 +00:00
|
|
|
{
|
2024-05-26 12:48:04 +00:00
|
|
|
return view(
|
|
|
|
'bookmarks.edit', [
|
2024-05-26 13:41:28 +00:00
|
|
|
'bookmark' => $bookmark,
|
2024-05-26 12:48:04 +00:00
|
|
|
]
|
|
|
|
);
|
2024-05-24 23:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*/
|
2024-05-26 13:41:28 +00:00
|
|
|
public function update(Request $request, Bookmark $bookmark)
|
2024-05-24 23:48:23 +00:00
|
|
|
{
|
2024-05-26 13:41:28 +00:00
|
|
|
$bookmark->title = $request->post('title');
|
|
|
|
$bookmark->description = $request->post('description', '');
|
|
|
|
$bookmark->href = $request->post('href');
|
|
|
|
$bookmark->save();
|
|
|
|
|
2024-05-30 20:55:08 +00:00
|
|
|
$bookmark->syncTagsFromString($request->post('tags', ''));
|
2024-05-29 21:07:23 +00:00
|
|
|
|
2024-05-26 13:41:28 +00:00
|
|
|
return redirect()->action(
|
|
|
|
[self::class, "show"], [
|
|
|
|
"bookmark" => $bookmark,
|
|
|
|
]
|
|
|
|
);
|
2024-05-24 23:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*/
|
|
|
|
public function destroy(string $id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|