Answers for "laravel model select columns"

PHP
7

laravel not in query

DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();
Posted by: Guest on September-26-2020
1

laravel eloquent get only field name

//Eloquent: Get specific columns (not all the row). Pluck returns an array.
Model::where('id', 1)->pluck('name', 'surname');
// If you only want to get the result value:
Model::where('id', 1)->value('name');
Posted by: Guest on May-17-2020
3

join in laravel eloquent

$customer = DB::table('customers')
                ->join('shops', 'customers.shop_id', '=', 'shops.shop_id')
                ->where('customer_contact', $contact_no)
                ->get();
Posted by: Guest on October-06-2020
1

eloquent get only some columns

Table::select('name','surname')->where('id', 1)->get();
Posted by: Guest on June-30-2020
0

eloquest how to select one specific column in database

ModelName::find($id, ['name', 'surname']);
Posted by: Guest on June-10-2020

Code answers related to "laravel model select columns"

Browse Popular Code Answers by Language