Article Detail

Title
Possimus doloremque quam id sint.
Author
Mozelle Emmerich

module structure


laravel/
├─ app/
│  ├─ Modules/
│  │  ├─ Demo/
│  │  │  ├─ Components/
│  │  │  │  ├─ Articles/
│  │  │  │  │  ├─ views/
│  │  │  │  │  │  ├─ articles_edit.blade.php
│  │  │  │  │  │  ├─ articles_table.blade.php
│  │  │  │  │  │  ├─ articles_view.blade.php
│  │  │  │  │  ├─ ArticlesEdit.php
│  │  │  │  │  ├─ ArticlesTable.php
│  │  │  │  │  ├─ ArticlesView.php
│  │  │  │  ├─ routes.php

route

Components/routes.php


Route::get('demo/article/view/{article:id}'ArticlesView::class)
    ->
middleware(['web'])
    ->
name('demo.articles.view')
    ->
crumbs(function ($crumbs$article) {
        
$crumbs->parent('demo.articles')->push('View Article'route('demo.articles.view'$article));
    });

component

Components/Articles/ArticlesView.php


<?php

namespace App\Modules\Demo\Components\Articles;

use 
App\Modules\Demo\Models\Article;
use 
Livewire\Component;


class 
ArticlesView extends Component
{
    public 
$article;

    public function 
mount(Article $article)
    {
        
$this->article $article;
    }

    public function 
render()
    {
        return 
view('demo::Articles.views.articles_view')->layout('demo::admin');
    }
}

view

Components/Articles/views/articles_view.blade.php


<x-rpd::card>
    <
x-rpd::view title="Article Detail">
      <
x-slot name="buttons">
        <
a href="{{ route('demo.articles') }}" class="btn btn-outline-primary">list</a>
        <
a href="{{ route('demo.articles.edit',$article->id) }}" class="btn btn-outline-primary">edit</a>
      </
x-slot>

      <
dl class="row">
        <
dt class="col-3">Title</dt>
        <
dd class="col-9">{{ $article->title }}</dd>
        <
dt class="col-3">Author</dt>
        <
dd class="col-9">
            {{ 
$article->author->firstname }}
            {{ 
$article->author->lastname }}
        </
dd>
      </
dl>

    </
x-rpd::view>
</
x-rpd::card>