php noob here - how should i create a crud page available to users

im confused between whether i should be using the admin panel, then conditionally render different resources if the user is an admin or not OR: make a custom page and then add a data table onto the page... sorry if my question is stupid the documentation isnt making sense to me and i cant find any example for what im looking for im basically trying to create something similar to medium.com
5 Replies
Tim van Heugten
Tim van Heugten6mo ago
Create a second panel for your users (ie. Admin vs App panel).
Dennis Koch
Dennis Koch6mo ago
Depends on how much both share. If only some functions are not available, I wouldn't create multiple panels. If there is too much difference between both, then create multiple panels.
travlatra
travlatraOP6mo ago
ahhh thanks i understand this perfectly now. i have 2 panels now. 1 for admin users to manage all rows, 1 for users to manage the rows that belong to themselves should i also create a seperate 'view only' panel to display the data to everyone?
LeandroFerreira
LeandroFerreira6mo ago
maybe a laravel scope? https://laravel.com/docs/11.x/eloquent#query-scopes
public function apply(Builder $builder, Model $model): void
{
$user = auth()->user();
$builder->when(! $user?->is_admin, fn ($query) => $query->whereUserId($user?->id));
}
public function apply(Builder $builder, Model $model): void
{
$user = auth()->user();
$builder->when(! $user?->is_admin, fn ($query) => $query->whereUserId($user?->id));
}
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Tim van Heugten
Tim van Heugten6mo ago
If the public version is like a medium.com it would probably be best outside a panel on a public route. That would be default Laravel stuff (including routes for catagories, topics, search, etc)
Want results from more Discord servers?
Add your server