Complete BLoC with Clean Architecture (group chat) Discount !! E-commerce App With Backend Source Code Video and Voice Chatting App Firebase Chatting App Source Code Complete Gym App BLoC State Management Source Code Complete Study App Buy Ticket Booking App Source Code Buy Travel App With Backend Source Code Complete Chat App Udemy Course Special Offer Discount !! Online Learning Course App (BLoC) Online Learning Course App (Riverpod) Online Learning Course App (Getx) Discount !! Shopping App (Provider) Cool Flutter Game Flutter Nodejs Chat App Flutter Nodejs Api And Firebase Chat App Riverpod Task Management App
Here we will cover the differences between Laravel Pluck() and Select() method. They are both part of Laravel collections. It means they are part of Laravel collection's methods.
This method retreives values based on
key value pair.
//get our categories $result = CourseType::pluck('id', 'title',); dd($result);
This would print the below results
You see from the code we passed id and title as arguments.
The second one works as key in the code.
So in our case title is the key. That's why you see the titles in the first column of the above photo. Values are the id on the right side.
You may also pass
only one argument, in that case, you will see the printed value on the right side.
//get our categories $result = CourseType::pluck('title',); dd($result);
Now see the result
Here we also see our titles are being printed. They are on the right side, meaning that it will give an id for title automitically.
These ID's are coming from database row. They are auto assigned.
Le'ts see another example
//get our categories $result = CourseType::pluck('description','title'); dd($result);
Now, here you see from the code, we are passing description and title. So titles are the keys and descriptions are the values.
And values are always put on the right side.
Now, pluck() method only takes two values for arguments. If you wanna pass more, you need to use select() method.