middleware
routes/web.php```
Route::group([‘prefix’ => ‘member’, ‘as’ => ‘member.’, ‘middleware’ => [‘auth’, ‘setLocale:zh-tw’]], function () {
Route::get('/', App\Http\Livewire\MemberList::class);
});
app/Http/Middleware/SetLocale.php.php``` namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; class SetLocale { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, string $lang) { app()->setLocale($lang); return $next($request); } }
https://github.com/livewire/livewire/issues/1908
https://www.youtube.com/watch?v=ShrS3HXwzPg```
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.
https://laravel-news.com/livewire-file-upload
Real-Time File Validation```
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 = []
Use - and lowwercase App/Http/Livewire/Order/DropdownMaterial.php```
class DropdownMaterial extends Component
{
resources/views/livewire/order/create.blade.php``` @livewire('order.dropdown-material', ['post' => $order_material_id])
When juse livewire at blade.php
Must have Div At first. <div style="text-align: center"> <button wire:click="increment">+</button> <h1>{{ $count }}</h1> </div> +{{ $count }}