Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Query Builder for Beginner In Laravel

1.Find Unique column and avoid duplicate column

3 method using distinct, groupby, pluck command

OR

OR

In above table triptitle field land of rising sun and windy city r unique land of rising 3 times repeated

2 Find unique record

$categories = Rvsp::distinct()->get();

3.count total no of rows

here total 4 rows are there

$Trips = DB::table(‘rvsps’)
->select(‘TripTitle’)
->distinct()->count();
return $Trips;

count{{$Trips}} in blade file

4.display unique field and their total no of entries

here trip title Land of the Rising Sun 3 times entry in table triptitle Windy City one times see in below table mentioned in screenshot image

$touroperator = Rvsp::where(‘TripTitle’,$TripTitle)->latest()->paginate(20);
->select(‘TripTitle’, DB::raw(‘COUNT(TripTitle) as total_member’))
->groupBy(‘TripTitle’)
->havingRaw(‘COUNT(TripTitle) > 0’)
->get();

5.display particular colunm that is requested in blade file

first check requested value in blade file

$tour->TripTitle is requested

requested value is land of rising sun

now find total record of requested value using this query
$touroperator = Rvsp::where(‘TripTitle’,$TripTitle)->latest()->paginate(20);

6.display particular colunm that is present in another table based on condition

display all city of india

here three table city,state,country is present

Firstly retrive all state from state table that is under india where india id is 101 using pluck command

  $states = State::where(‘states.country_id’,’101′)->get();

then pass this variable to where condition to match all cities that is under india state

 $city = DB::table(‘cities’)->whereIn(‘cities.state_id’, $states)->get();

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals

Related Posts

What is Laravel and use cases of Laravel?

What is Laravel? Laravel is an open-source, free PHP web framework designed for the development of web applications following the model-view-controller (MVC) architectural pattern. It was generated…

Read More

Complete guide of Laravel certification courses, tutorials & training

What is Laravel Laravel is a reliable and simple to use open-source PHP framework. It adheres to the model-view-controller pattern of design. Laravel makes use of pre-existing…

Read More

Top 100 laravel interview questions and answers

1) What is Laravel? Laravel is an open-source widely used PHP framework. The platform was intended for the development of web application by using MVC architectural pattern….

Read More

[SOLVED] Laravel : Supervisor FATAL/BACKOFF Exited too quickly (process log may have details)

Problem I’m trying to use Laravel queues with a supervisor but the service is not working properly. When I try to check status:$ sudo supervisorctl status$ laravel-worker:laravel-worker_00:…

Read More

How to Login with Token in Laravel PHP Framework?

How to Login with Token in Laravel PHP Framework? Step 1. Create a new Project, so write down the following command on Git Bash: Step 2. Move…

Read More

Directory Structure Of Laravel Application

devopsschool – This is Project Folder app – The app directory contains the core code of your application. bootstrap – The bootstrap directory contains the app.php file…

Read More