Examples
Detail view examples
Error!
Success!
belal ddx
User profile data
-
Avatar
-
Namebelal ddx
-
Emaildaadadakk
-
Active
-
Typewriter
-
Created1 year ago
-
Updated15 hours ago
<?php
namespace App\Http\Livewire\DetailView;
use App\Models\User;
use LaravelViews\Facades\UI;
use LaravelViews\Views\DetailView;
class UserDetailView extends DetailView
{
protected $modelClass = User::class;
public function heading(User $model)
{
return [$model->name, 'User profile data'];
}
/**
* @param $model Model instance
* @return Array Array with all the detail data or the components
*/
public function detail(User $model)
{
return [
'Avatar' => UI::avatar(asset('storage/' . $model->avatar)),
'Name' => $model->name,
'Email' => $model->email,
'Active' => $model->active ? UI::icon('check', 'success') : UI::icon('slash', 'danger'),
'Type' => $model->type,
'Created' => $model->created_at->diffForHumans(),
'Updated' => $model->updated_at->diffForHumans(),
];
}
}
Error!
Success!
belal ddx
User profile data
Change user as admin
Change user as writer
Activate / Deactivate
-
Avatar
-
Namebelal ddx
-
Emaildaadadakk
-
Active
-
Typewriter
-
Created1 year ago
-
Updated15 hours ago
<?php
namespace App\Http\Livewire\DetailView;
use App\Actions\ChangeUserAsAdmin;
use App\Actions\ChangeUserAsWriter;
use App\Actions\ToggleUserAction;
class UserDetailViewWithActions extends UserDetailView
{
public function actions()
{
return [
new ChangeUserAsAdmin,
new ChangeUserAsWriter,
new ToggleUserAction,
];
}
}
Error!
Success!
belal ddx
User profile data
Change user as admin
Change user as writer
Activate / Deactivate
Name
belal ddx
Email
daadadakk
Active
0
Type
Writer
Created
1 year ago
Updated
15 hours ago
<?php
namespace App\Http\Livewire\DetailView;
class UserDetailViewWithCustomComponent extends UserDetailViewWithActions
{
protected $detailComponent = 'components.user-detail';
/**
* @param $model Model instance
* @return Array Array with all the detail data or the components
*/
public function detail($model)
{
return [
'user' => $model,
];
}
}
Error!
Success!
belal ddx
User profile data
Change user as admin
Change user as writer
Activate / Deactivate
230k
Sales
230k
Sales
230k
Sales
-
Avatar
-
Namebelal ddx
-
Emaildaadadakk
-
Active
-
TypeWriter
-
Created1 year ago
-
Updated15 hours ago
Gallery
<?php
namespace App\Http\Livewire\DetailView;
use LaravelViews\Facades\UI;
class UserDetailViewWithMultipleComponents extends UserDetailViewWithActions
{
/**
* @param $model Model instance
* @return Array Array with all the detail data or the components
*/
public function detail($model)
{
return [
UI::component('components.metrics', []),
UI::attributes([
'Avatar' => UI::avatar(asset('storage/' . $model->avatar)),
'Name' => $model->name,
'Email' => $model->email,
'Active' => $model->active ? UI::icon('check', 'success') : UI::icon('slash', 'danger'),
'Type' => ucfirst($model->type),
'Created' => $model->created_at->diffForHumans(),
'Updated' => $model->updated_at->diffForHumans(),
]),
UI::component('components.gallery', []),
];
}
}