Reputation: 95
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.
Upvotes: 3
Views: 28894
Reputation: 266
public function getAllData()
{
$data = tableName::where('Method','Delivery')->get();
return response()->json($data, 200);
}
OR
$users = DB::table_Name('users')->select('name', 'email as user_email')->get();
OR
$users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
Upvotes: 2
Reputation: 3299
The eloquent query is something like this:
FodMap::where('name','=',$name)->where('category','=',$category)->get()
That will return an Eloquent Collection instance.
Upvotes: 5