some progress: users slugs, bookmarks page, upvotes page, design
This commit is contained in:
@@ -67,6 +67,7 @@ class RegisterController extends Controller
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
'slug' => User::generateUniqueSlug($data['name']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,24 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class BookmarkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the user's bookmarked products.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$bookmarks = $user->bookmarks()
|
||||
->with(['product.category', 'product.user'])
|
||||
->whereHas('product', function ($query) {
|
||||
$query->approved();
|
||||
})
|
||||
->latest()
|
||||
->paginate(12);
|
||||
|
||||
return view('bookmarks.index', compact('bookmarks'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle bookmark for a product.
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,11 @@ class ProfileController extends Controller
|
||||
$validated['avatar'] = $avatarName;
|
||||
}
|
||||
|
||||
// Regenerate slug if name changed
|
||||
if ($request->name !== $user->name) {
|
||||
$validated['slug'] = User::generateUniqueSlug($request->name);
|
||||
}
|
||||
|
||||
// Update user profile
|
||||
$user->update($validated);
|
||||
|
||||
|
||||
@@ -10,6 +10,24 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UpvoteController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the user's upvoted products.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$upvotes = $user->upvotes()
|
||||
->with(['product.category', 'product.user'])
|
||||
->whereHas('product', function ($query) {
|
||||
$query->approved();
|
||||
})
|
||||
->latest()
|
||||
->paginate(12);
|
||||
|
||||
return view('upvotes.index', compact('upvotes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle upvote for a product.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user