What seems to be the problem:
Dropdown working just fine, but when I choosed on of the data from category dropdown just showed up the error.
Error:
Livewire\Exceptions\PropertyNotFoundException
Property [$kategori] not found on component: [posts]
I was trying to get data from my Kategori table and fetched it to dropdown in Post page, the data appears in the dropdown, but when I selected one of the data in the dropdown then the error appears.
Are you using the latest version of Livewire: 2.0
My Post Table:
id | kat_id | title | content
My Kategori Table:
id | nama_kategori
Do you have any screenshots or code examples:
My create-post.blade
My Posts Controller
namespace App\Http\Livewire;
use Livewire\Component;
use App\Kategoris;
use App\Models\Post;
use App\Models\Kategori;
class Posts extends Component
{
public $posts, $title, $content, $post_id;
public $kategoris;
public $isOpen = 0;
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function render()
{
$this->posts = Post::all();
$this->kategoris = Kategori::all();
return view('livewire.posts');
}
My Post Model
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'kat_id', 'title', 'slug', 'content',
'picture', 'tag', 'publish',
];
}
My Route
use Illuminate\Support\Facades\Route;
use App\Http\Livewire\Kategoris;
use App\Http\Livewire\Posts;
Route::get('kategori', Kategoris::class)->name('kategori');
Route::get('post', Posts::class)->name('post');
I’m newbie using livewire, I’m very sorry for the inconvenience, any help would appreciate. Thank you so much.