Laravel views
Twitter Github
Examples

Detail view examples

Error!
Success!
aboulfazlmm
User profile data
  • Avatar
    https://laravelviews.com/storage/avatar/51.png
  • Name
    aboulfazlmm
  • Email
    ebrahimi
  • Active
  • Type
    admin
  • Created
    1 year ago
  • Updated
    11 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!
aboulfazlmm
User profile data
  • Avatar
    https://laravelviews.com/storage/avatar/51.png
  • Name
    aboulfazlmm
  • Email
    ebrahimi
  • Active
  • Type
    admin
  • Created
    1 year ago
  • Updated
    11 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!
aboulfazlmm
User profile data
Name
aboulfazlmm
Email
ebrahimi
Active
0
Type
Admin
Created
1 year ago
Updated
11 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!
aboulfazlmm
User profile data
230k
Sales
230k
Sales
230k
Sales
  • Avatar
    https://laravelviews.com/storage/avatar/51.png
  • Name
    aboulfazlmm
  • Email
    ebrahimi
  • Active
  • Type
    Admin
  • Created
    1 year ago
  • Updated
    11 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', []),
        ];
    }
}