Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of data with where condition in Laravel 5

I want to get REST url to retrieve data where name="hello" and category="main"

This is my Model

public function show($name, $category)
    {
        $FodMap = FodMap::find($name, $category);
        return $FodMap;


    }

Routes

Route::get('FodMap/{name}/{category}', 'FodMapController@show');

What I want is when I type localhost/api/FodMap/hello/main

All result should display which matches with hello and main

Please advise me to proceed.... I'm new to Laravel.

like image 570
jzon Avatar asked Jan 20 '26 16:01

jzon


1 Answers

The eloquent query is something like this:

FodMap::where('name','=',$name)->where('category','=',$category)->get()

That will return an Eloquent Collection instance.

like image 105
Arthur Samarcos Avatar answered Jan 23 '26 07:01

Arthur Samarcos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!