livewire checkbox

php``` public $check_items; public function mount() { $this->check_items = collect([“png” => true, “scs” => true, “scz” => false, “xml” => true, “pdf” => false, ]); } blade``` @forelse($check_items as $index => $item) @empty @endforelse

2021-09-29 · 1 min · 34 words · Me

livewire public variable eloquent for security column

Get livewire public variable Front web Try to get public $order``` document.addEventListener(’livewire:load’, function () { console.log(@this.order); livewire window.livewire.find eloquent collection https://github.com/livewire/livewire/issues/1641?fbclid=IwAR0uHylkj-1vg8p5jUoBgPYfuAYsWnBhgp6EK2bJcBce8ze-tdtAa8ElLNY#issuecomment-736146468 Eloquent Collection data won't be made available to the front end unless you have the collection properties specified in the $rules array as the contents are models, so the same conditions apply to it as apply to just a single model property. This is for security reasons so the whole collection and all properties aren't just sent to the front end. See the example here of binding to an eloquent collection https://laravel-livewire.com/docs/2.x/properties...... But a standard collection (not eloquent) will work but only with primitive data types. If any models are added to the collection or any php objects (not eloquent models), they will be serialised into an array. So eloquent use for public variable is OK. \====== Other way use makeHidden()

2021-03-30 · 1 min · 142 words · Me

livewire locale lang

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); } }

2021-02-24 · 1 min · 60 words · Me

Search two time then change paginate table record have problem

https://github.com/livewire/livewire/issues/1908

2020-10-29 · 1 min · word · Me

laravel livewire file update Real-Time File Validation mutile files

 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 = []

2020-10-21 · 1 min · 66 words · Me