use model in laravel code example
Example 1: how to create model in laravel
php artisan make:model Flight
Example 2: laravel create on model
$user = User::create([
'first_name' => 'Taylor',
'last_name' => 'Otwell',
'title' => 'Developer',
]);
$user->title = 'Painter';
$user->isDirty();
$user->isDirty('title');
$user->isDirty('first_name');
$user->isClean();
$user->isClean('title');
$user->isClean('first_name');
$user->save();
$user->isDirty();
$user->isClean();
Example 3: laravel find query
foreach (Flight::where('foo', 'bar')->cursor() as $flight) {
}
Example 4: laravel find query
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Flight extends Model
{
protected $primaryKey = 'flight_id';
}