App/Http/Livewire/Orders.php
namespace App\Http\Livewire;
use Gate;
use Livewire\Component;
use Symfony\Component\HttpFoundation\Response;
class Orders extends Component
{
public function render()
{
abort_if(Gate::denies('order_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');
return view('livewire.order');
}
}
resources/views/livewire/order.blade.php
@extends('layouts.app')
@section('content')
@livewire('order.show')
@endsection
App/Http/Livewire/Order/Show.php
namespace App\Http\Livewire\Order;
public function render()
{
abort_if(Gate::denies('order_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');
$this->orders = Order::all();
// Order::where('owner_id', auth()->id())->get(); // 只能看自己
return view('livewire.order.show');
}
resources/views/livewire/order/show.blade.php
{{ virables }}