where eloquent code example

Example 1: laravel create model

# The easiest way to create a model instance is using the 
# make:model Artisan command:

php artisan make:model Flight

# If you would like to generate a database migration when you 
# generate the model, you may use the --migration or -m option:

php artisan make:model Flight --migration
php artisan make:model Flight -m

Example 2: eloquent where in

$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get()

Example 3: laravel create or update

// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Models\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99, 'discounted' => 1]
);

Example 4: where () laravel Eloquent

//los signos de igualdad pueden ser: ">=", "<=", "=", ">", "<"
$user = User::where("estado","=",1)->find(10);

Example 5: laravel where

$users = DB::table('users')
                ->whereMonth('created_at', '12')
                ->get();

Example 6: laravel where

$users = DB::table('users')
                ->whereDate('created_at', '2016-12-31')
                ->get();