mafortis
mafortis

Reputation: 7128

Laravel advanced search guide

I would like to ask your suggestions about laravel advanced search, currently I'm working on e-commerce website where i need to make search form which user could choose any field in the form including price range or category or brands etc. and get the results back.

Now my question is what do you suggest that I use Laravel Scout or make custom function such as code below and extend it?

$query = DB::table('rooms')
        ->join("salereservation", "salereservation.room_id", "=", "rooms.room_id")
        ->join("customers", "customers.id", "=", "salereservation.customer_id")
        ->where("salereservation.sale_status",'=',1)
        ->select('rooms.*', 'salereservation.*', 'customers.*');

if($fname!=''){
    $query->where("fname",'like',"%$fname%");
}

if($lname!=''){
    $query->where("lname",'like',"%$lname%");
}
if($time_in!=''){
   $query->where("start_datetime",'like',"%$time_in%");
}
if($time_out!=''){
    $query->where("end_datetime",'like',"%$time_out%");
}
if($phone!=''){
    $query->where("phone",'like',"%$phone%");
}
if($room_no!=''){
  $query->where("room_no",'like',"%$room_no%");
}
$data = $query->get(); //finally get the result

Obviously code above is not with options i need - Source

Please help me to make the right decision.

PS: database of this application will be massive so I need something to work with big database.

Thank you.

Upvotes: 0

Views: 760

Answers (2)

Keval Mangukiya
Keval Mangukiya

Reputation: 2491

yes,you can use laravel scout if your functionality is heavy. or if you make normal functionality than you can use your costume function. now your choices which can you use ?

Upvotes: 0

Alireza Amrollahi
Alireza Amrollahi

Reputation: 915

There are some options i'm gonna describe them for you : 1-Simple eloquent( or raw) queries in laravel, it's not awefull but it has it's downsides like the code is messy and performance is not great and so is the UX . 2- There's algolia , it's user friendly , easy to setup but it's pretty expensive( believe me i know ) . 3- Lastly use ELASTICSEARCH , it's a search engine like algolia but with cheater pricing and more options and you can config it how ever you want .

Upvotes: 2

Related Questions