Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.
// Dans le modèle : protected $fillable = ['name'];
$flight = Flight::create(['name' => 'London']);
$users = User::where('active', 1)->orderBy('name')->get();
$flight = new Flight;
$flight->name = 'Paris';
$flight->save();
$books = Book::with('author')->get();
$flight = Flight::find(1);
$flight->name = 'San Diego';
$flight->save();
$flights = Flight::all();
public function roles()
{
return $this->belongsToMany(Role::class);
}
public function posts()
{
return $this->hasMany(Post::class);
}
public function phone()
{
return $this->hasOne(Phone::class);
}
// Dans le modèle : use SoftDeletes;
Flight::find(1)->delete();
$flight = Flight::find(1);
$flight->delete();
$flight = Flight::find(1);