Laravel 8 tutorial -  Search API

Laravel 8 tutorial - Search API

Code Step By Step

3 года назад

37,911 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Nermen Es
Nermen Es - 13.08.2023 18:24

❤❤❤

Ответить
Fuad Abdurahman officials
Fuad Abdurahman officials - 18.02.2023 11:40

please use the simple method for example the following code is simpler
use App\Models\Stud;

class devicecontroller extends Controller
{
//
function Index(Stud $key){
return $key;
}

Ответить
amouchaldev
amouchaldev - 07.11.2022 15:24

It's not good to use % at begining of search

Ответить
Suneth Senanayake
Suneth Senanayake - 28.07.2022 20:14

function search($model) {
$result = Car::where("model","like","%".$model."%")->get();

if(!$result->isEmpty()){
return $result;
}else{
return ['Result' =>'No result found'];
}

}

Ответить
MD RABIULL HASSAN
MD RABIULL HASSAN - 29.01.2022 21:45

function search($name)
{
$result = Test::where("name", "like", "%" . $name . "%")->get();
if(count($result))
{
return $result;
}
else
{
return ['Result'=>'No records found'];
}
}

Ответить
destiny obamwonyi
destiny obamwonyi - 04.01.2022 15:06

The answer is to simply find a way to check if the array is empty as any value returned by the get statement is in form of an array , so a very simple way to check will be as shown below .

function search($firstname)
{
$result = Member::where("firstname", $firstname)->get();

if(sizeof($result) == 0)
{
return "There are no Match";
}

else
{
return $result;
}

}

Your can also do the same if you are checking for a character .

Ответить
Danang Gml
Danang Gml - 15.11.2021 14:32

soo helpfull

Ответить
Technical Shyab
Technical Shyab - 27.10.2021 17:51

Tq u so much luv u sir

Ответить
Sagar Pandey
Sagar Pandey - 18.08.2021 11:08

function search($name){
$data = Organizations::where("name","like","%".$name."%")->get();
if($data)
{
return $data;
}
else{
return ["Result"=>"no data found"];
}
}

Ответить
William Burt
William Burt - 03.08.2021 15:55

Another Answer:

    public function search($name){

        $result = Devices::where("name",$name)->get();

        if(!$result->isEmpty()){
            return $result;
        }
        else{
            return response()->json([
                'response'=>'No data found'            
            ]);


        }

    }

Ответить
Ricardo Lopez
Ricardo Lopez - 13.06.2021 08:17

Crack

Ответить
Martinho Correia Mussamba
Martinho Correia Mussamba - 22.03.2021 02:30

function search($name)
{
$devices = Device::where("name","like", "%".$name."%")->get();

return count($devices)?$devices:["message"=>"".$name." not found"];

}

Ответить
Numan Siddique
Numan Siddique - 20.03.2021 22:28

$data = Data::where('name','like','%'.$q.'%')->get();
if (count($data)) {
return $data;
}else{
return [
'status' =>false,
'message' => 'not found',
];
}

Ответить
Benedict Deke
Benedict Deke - 23.02.2021 23:57

function search($key){
        $result = Device::where("name", "LIKE", "%".$key."%")->get();
        
        if($result->count()>0){
            return $result;
        }else{
            return ["Result"=>"No records found"];

        }
        
    }

Ответить
Toghrul Rahimli
Toghrul Rahimli - 26.01.2021 22:08

i think this is the shortest, lol

if ($result == '[]') {
return 'bruh...';
} else {
return $result;
}

Ответить
GØD
GØD - 25.01.2021 20:29

Sir, how to fetch data from multiple endpoints in single endpoint

Ответить
MD Nafish Fuad Tushar
MD Nafish Fuad Tushar - 20.01.2021 13:19

Make tutorial with number list

Ответить
Nadin Manimel Wadu
Nadin Manimel Wadu - 14.01.2021 13:14

public function search($name)
{
$result= Device::where('name',"like","%".$name."%")->get();
return(isset($result))?$result:['Result'=>'No Records found'];
}

Ответить
ehtesam esan
ehtesam esan - 13.01.2021 02:24

return count($result)? $result:"Not matched";

Ответить
Diana Eftaiha
Diana Eftaiha - 04.01.2021 18:31

Answer:

public function search ($name){
$result = User::where('username', 'like', '%'.$name.'%')->get();
if(count($result)){
return $result;
} else {
return array('Result', 'No records found');
}
}

Ответить
Shaiful Islam
Shaiful Islam - 31.12.2020 19:14

function search($haider){
$member= Member::where("name",$haider)->get();
$result = $member;
if($result){
return $result;

}
else{
return ['result'=>'Your searching data does not matched!!'];

}

}

but dont show message !!

Ответить
Belajar Frontend
Belajar Frontend - 29.12.2020 05:00

Interview answer:

$result = (Devices::where("name", "like", "%" . $name . "%")->get());
if ($result->count() > 0) {
return $result;
}
return [
"result" => "There is no result found"
];

Ответить
Rohit Prabhakar
Rohit Prabhakar - 21.12.2020 23:08

Would it be possible to show how to implement SOAP API's using laravel please

Ответить
Rohit Prabhakar
Rohit Prabhakar - 21.12.2020 23:07

function search($name)
{
$result= Device::where("name",$name)->get();

if (!count($result))
{
return ["result"=>"no result found"];

}
else
{
return $result;
}

}

Ответить
Respect 5👑
Respect 5👑 - 18.12.2020 09:04

bro how integrate laravel with reactjs

Ответить
Sargis Grigoryan
Sargis Grigoryan - 23.11.2020 17:44

Interview question:

function search($name){
$result = Device::where('name', 'like', '%'.$name.'%')->get();
if(count($result) > 0){
return $result;
}else{
return $name." is not found";
}
}

Ответить
Trần Anh Tuấn
Trần Anh Tuấn - 23.10.2020 11:32

thank you very much

Ответить
ARUN RAJ KUMAR D
ARUN RAJ KUMAR D - 19.10.2020 06:50

If($device→count() > 0)

Ответить
Ramu Ramu
Ramu Ramu - 30.09.2020 09:54

Sir how to create api key for nobody can use Ower api

Ответить
Shoccho Solutions
Shoccho Solutions - 29.09.2020 23:48

Can we use post method here

Ответить
Stiphen
Stiphen - 29.09.2020 21:29

Sir ek html template ko kaise laravel me integrate karenge plz ospe ek video banado

Ответить
Babul Jack
Babul Jack - 29.09.2020 21:06

please make videos on the Role management based Multiple Authentication system...... It's really indeed..

Ответить