// Retrieve a model by its primary key...$flight=AppModelsFlight::find(1);// Retrieve the first model matching the query constraints...$flight=AppModelsFlight::where('active',1)->first();// Shorthand for retrieving the first model matching the query constraints...$flight=AppModelsFlight::firstWhere('active',1);
<?phpnamespaceAppModels;useIlluminateDatabaseEloquentModel;classFlightextendsModel{/**
* The primary key associated with the table.
*
* @varstring
*/protected$primaryKey='flight_id';}
Visitor::select('country')->withCount('id')->groupBy('country')->latest()->get()//orVisitor::query()->groupBy('country')->orderByDesc('count')->select('country',DB::raw('COUNT(1) as count'))->get()
<?phpnamespaceAppModels;useIlluminateDatabaseEloquentModel;classFlightextendsModel{/**
* The connection name for the model.
*
* @varstring
*/protected$connection='connection-name';}