skip to Main Content

livewire array inputs how to fix? – Laravel

my component livewire public $images = []; public function rules() { return [ 'images.*.name' => 'required|max:255', ]; } blade.php <div id="images"> @foreach($images as $index => $image) <div class="card" wire:key="image-field-{{$images[$index]['id']}}"> <img src="{{$images[$index]->original_url}}" class="card-img-top" alt="{{$images[$index]->name}}" /> <input type="text" name="item-{{$index}}-name" id="item.{{$index}}.name" wire:model="images.{{$index}}.name" />…

VIEW QUESTION

laravel relationship method working incorect

Method in model User public function news() { return $this->hasMany(News::class); } Method in model News public function user() { return $this->belongsTo(User::class); }; Work $user=User::all(); dd($user[0]->news->user->name); Not work $news=News::all(); dd($news[0]->user->name); But array objects 'news' i getted

VIEW QUESTION
Back To Top
Search