dimanche 13 décembre 2020

Laravel not calling function inside if statement

In laravel 8 I'm trying to pass data to the view blade template. This is my code:

Route::get('/admin', function(){
    if (session()->has('username')) {
        return view('admin', ["privatecars"=>[privatecar::class, 'list'], "businesscars"=>[businesscar::class, 'list']]);
    } else {
        session()->flash('blocked', 'true');
        return redirect('');
    }
});

I thought that it should call the function inside [privatecar::class, 'list'] and return the results but it just returns Array ( [0] => App\Http\Controllers\privatecar [1] => list ) . How should I do to call the function?

PS: I am using laravel8

Aucun commentaire:

Enregistrer un commentaire