class PostController extends Controller
{
public function update(Post $post,
before
class PostController extends Controller
{
public function update($post_id,
$post = Post::findOrFail($post_id);
And many more things.
class PostController extends Controller
{
public function update(Post $post,
before
class PostController extends Controller
{
public function update($post_id,
$post = Post::findOrFail($post_id);
And many more things.
php artisan view:clear
https://laracasts.com/discuss/channels/laravel/permission-denied-on-storageframeworkviews
https://laravel.io/forum/07-06-2016-session-permissions-issue
https://laracasts.com/discuss/channels/general-discussion/laravel-framework-file-permission-security
https://laravel-news.com/livewire-file-upload
use Livewire\Component;
use Livewire\WithFileUploads;
class Show extends Component
{
use WithFileUploads;
public $files = [];
public function updatedFiles() // 即時檢查檔案格式
{
$this->validate([
'files.*' => 'image|max:1024', // 1MB Max
]);
}
public function store()
{
$filenames = collect($this->photos)->map->store('photos');
'files' => $filenames->implode(','),
updatedFiles() is Hook into the “updated”
updatedPhoto public $Photo
updatedPhotos public $photos = []
updatedFile public $file
updatedFiles public $files = []
class DropdownMaterial extends Component
{
resources/views/livewire/order/create.blade.php
@livewire('order.dropdown-material', ['post' => $order_material_id])
<div style="text-align: center">
<button wire:click="increment">+</button>
<h1>{{ $count }}</h1>
</div>
<div>
<button wire:click="increment">+</button>
<h1>{{ $count }}</h1>
<button class="btn btn-success btn-block" wire:click="create">
{{ trans('global.add') }} {{ trans('cruds.order.title_singular') }}
</button>
</div>
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 }}