Item Management
All three types of users have access to a tags management table page.
Item Management is the most advanced example included in the PRO theme because every item has a
picture, has a category and has multiple tags. The item management can be accessed by clicking
Item Management
from the Laravel Examples section of the sidebar. The
authenticated user as an Admin or Creator is able to add, edit and
delete items. For adding a new item you can press the + Add Item button. If you would
like to edit or dea tag you can click on the Action column. It is also possible to sort the
fields or to sein the fields.
On the page for adding a new item you will find a form which allows you to add an image of the item, to fill the name, description of the item, a dropdown to choose the category and a multiselect for the tags.
The App/Http/Livewire/LaravelExamples/Items/Create.php
handles data validation when adding a new item and the item creation
public function store(){
$this->validate();
$item = Item::create([
'name' => $this->name,
'category_id' =>$this->category_id,
'description' => $this->description,
'picture' => $this->picture->store('pictures', 'public'),
'status' =>$this->status,
'options' => $this->options,
'homepage' => $this->showOnHomepage ? 1 : 0,
'date' => Carbon::parse($this->date)->format('Y-m-d')
]);
sort($this->tags_id);
$item->tag()->sync($this->tags_id, false);
return redirect(route('item-management'))->with('status','Item successfully created.');
}
The policy which authorizes the user to access item management pages is implemented in
App\Policies\ItemPolicy.php
.