Laravel 8 tutorial - get API with params

preview_player
Показать описание
In this laravel 8 hindi tutorial, we learn what is the API and how to make the get API with a database in a simple way. This video is made by anil Sidhu in the Hindi language.

Laravel restfull api tutorial

steps of video
Pass Params with Routing
Condition with Route
Apply Condition with the result
Other Options
Interview Question
Рекомендации по теме
Комментарии
Автор

to get a data using name parameter, first we have to define the route:
=> Route::get('/list/{name}, '[DeviceController::class, 'getListByName']);
and then in the getListByName() function we do like this:

getListByName($name){
return Device::where('name', $name)->first();
}

that should do it.

nurulazimsabbir
Автор

Please make a video on solutions to all the interview questions you are covering in the playlist. Just a suggestion. By the way, love your content.

anishagoyal
Автор

function name($name=null, $quantity=null){

$success=device::select('name', 'quantity')
->where('name', $name)
->orWhere('quantity', $quantity)
->get($name, $quantity);
return $success;
}

mikhailrudoy
Автор

Man you are perfect !!! thanks for this series

MuhammadAli-fnxb
Автор

Pls do answer ur interview question sir.

deepthim
Автор

I tried by using (User $user->name) parameter and it returned nothing to me. What should I do, sir? I can't find the answer.

leloughlemperough
Автор

how to consume this json data and show it in table form ui.

ansarihifzurrahman
Автор

But I don’t want to show all data,
I just want to show limited data from my database ??
How can I ?
Like we fix limit 30 in Php that show only 30 entries ...

musiclovers
Автор

how to retrieve data from another site via an API

sanjarkalandarov
Автор

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Students;
use DB;

class ApiController extends Controller
{
public function show($id=null){
if($id!=null){
$users = Students::find($id);
return ['user'=>$users];

}else{
$users = DB::table("students")->get();
return ['user'=>$users];
}



}
}

microcodes
Автор

public function getData($member_id=null){

$success = $member_id?team::
where('member_id', $member_id)
->get():team::all();

return response()->json($success);
}

Hasanhasanhsan
Автор

yes
file
Route::get("data/{data}", [DummyapiController::class, 'listdata']);


function listdata($data){
$data = organizations::where('id', $data)
->orWhere('name', 'like', '%'.$data.'%')
->orWhere('phone', $data)->get();
if(!empty($data)){
return $data;
}else{
$obj = "This Data Not in the Table Sorry !!";
return $obj;
}
}

sagarpandey
Автор

route::get("demo_api_list/{name?}", [demoApicontroller::class, 'demo_list']);


public function demo_list($name=null){

return $name?device::where('name', $name)->get():device::all();

}

result:
[{"id":3, "name":"tv1", "price":"120", "created_at":null, "updated_at":null}, {"id":7, "name":"tv1", "price":"120", "created_at":null, "updated_at":null}]

ManojChauhan-qkrd