Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attribute [livewire] does not exist

I am having trouble to run my code on Laravel 8 routing with laravel-livewire.
The class is within Livewire\LandingPage.

The error I'm getting is

Attribute [livewire] does not exist

Here are my routes

<?php

use Illuminate\Support\Facades\Route;

Route::livewire('/' , 'LandingPage');

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');
like image 228
swatantra Avatar asked Sep 13 '20 03:09

swatantra


2 Answers

If you are using a recent install of Laravel 8, you will have Livewire V2. In this version, Route::livewire()has been removed. Instead, you specify a normal get() route, with the action being the Livewire component class.

Route::get('/' , App\Http\Livewire\LandingPage::class);
like image 52
Qirel Avatar answered Nov 01 '22 21:11

Qirel


If you use livewire v1.x please use this annotation :

//(livewire v1.x)
Route::livewire('/post', 'LandingPage');

If you are using livewire v2.0 please use this one :

//(livewire v2.x)
Route::get('/post', \App\Http\Livewire\LandingPage::class);
like image 6
stic-lab Avatar answered Nov 01 '22 23:11

stic-lab