“LARAVER CREATE Метод” Ответ

Laravel UpdateorTorcete

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

Laravel создать или обновить

// 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]
);
Embarrassed Eel

Создайте новую запись через модель в Laravel

$userData = array('username' => 'Me', 'email' => 'me@yahoo.com');
User::create($userData);
Romesh Fernando

Красноречивая FirstorCreate

firstOrCreate() will automatically create a new entry in the database if there is not match found. Otherwise it will give you the matched item.
firstOrNew() will give you a new model instance to work with if not match was found, but will only be saved to the database when you explicitly do so (calling save() on the model). Otherwise it will give you the matched item.
Quaint Quetzal

LARAVER CREATE Метод

Alternatively, there's also a create method which accepts a plain PHP array instead of an Eloquent model instance.
$post = Post::find(1);

$post->comments()->create([
    'message' => 'This is a new comment message'
]);
Tough Tapir

LARAVER CREATE Метод

 public function create()
    {
        return view('post.create');
    }
WinMaw

Ответы похожие на “LARAVER CREATE Метод”

Вопросы похожие на “LARAVER CREATE Метод”

Больше похожих ответов на “LARAVER CREATE Метод” по PHP

Смотреть популярные ответы по языку

Смотреть другие языки программирования