So I'm new in laravel and I'm trying to create a rest api to return a specific item of my data database
http://127.0.0.1:8000/api/items/1010100203
And I'm getting []
So I have a array of json objects like
[{"No_":"1010100203","Price:"23","Description":"Item1"},{"No_":"1010100204","Price":"15","Description":"Item2"},{"No_":"1010100205","Price":"12","Description":"Item3"}]
in my database and I want to get my item with "No_" 1010100203.
In controller I have this function
public function find($id){
return Item::where('No_', 'like', $id)->get();
}
I've also tried to create a find function to only return $item and also returned []
I think I need to parse my array but I don't know how to do this..
And in my route api file,
Route::get('items/{id}', 'ItemController@find');
Also tried with Manager,
ItemController,
public function find($id){
$im= new ItemManager();
if (!empty($id))
$i=$im->GetItemIfExist($id);
return $i;
}
ItemManager
public function GetItemIfExist($id){
$result=\Illuminate\Support\Facades\DB::table('MR$Item')
->where('No_',$id)
->get();
return $result;
}