📜  laravel firstorcreate 用法 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:43.008000             🧑  作者: Mango

代码示例1
// Retrieve flight by name, or create it if it doesn't exist...
$flight = App\Flight::firstOrCreate(['name' => 'Flight 10']);

// Retrieve flight by name, or create it with the name, delayed, and arrival_time attributes...
$flight = App\Flight::firstOrCreate(
    ['name' => 'Flight 10'],
    ['delayed' => 1, 'arrival_time' => '11:30']
);