mardi 23 octobre 2018

Retrieving rows from DB which contains same value in Laravel

Trying to retrieve rows which has same value(関西).

First I created a blade for this (kansai.blade) And then I set the route:

Route::get('pages/kansai', 'PagesController@kansai');

I set the controller:

public function kansai()
{

    $estates = allestates::where('region', '=', '関西')->get();

    return view('pages.kansai', compact('estates'));

}

After that gave the link in main.blade:

<li><a href="/pages/"></a>関西</li>

But it returns with an error:

Trying to get property of non-object (View: /var/www/html/laravel/resources/views/welcome.blade.php)

also in the pages/kansai I'm getting this method error too.

Method Illuminate\Database\Eloquent\Collection::appends does not exist.

Do I missing something here? The problem is my controller I guess? Any idea? Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire