“Tanggal Benih Laravel” Kode Jawaban

Laravel Run Seed

#All of them
php artisan db:seed
#One class
php artisan db:seed --class=UserSeeder
Eranot

Tanggal Benih Laravel

use Carbon\Carbon;

Setting::create([
    'name' => 'Start Date',
    'date' => Carbon::parse('2000-01-01')
]);
NachooCh

Kolom cap waktu biji Laravel

DB::table('menu_types')->insert([ 'title' => 'Footer', 'description' => str_random(10), 'created_at' => date("Y-m-d H:i:s") ]);


---------------------

Auto timestamp saving is only for Eloquent feature so you need to do manually like below for non eloquent feature

DB::table('languages')->insert([
    'name'        => 'English',
    'flag'        => '',
    'abbr'        => 'en',
    'script'    => 'Latn',
    'native'    => 'English',
    'active'    => '1',
    'default'    => '1',
    'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
    'updated_at' => Carbon::now()->format('Y-m-d H:i:s')

]);
OR do it eloquently(Like you have seen in auto generated seeds like UserTableSeeder)

    $language = new Language();
    $language ->name = 'English';
    $language->flag'  = '',
    $language ->abbr  = 'en',
    $language->script ='Latn',
    $language->native ='English',
    $language->active ='1',
    $language->default ='1',
    $language->save();
Valentino_Rossi

Jawaban yang mirip dengan “Tanggal Benih Laravel”

Pertanyaan yang mirip dengan “Tanggal Benih Laravel”

Lebih banyak jawaban terkait untuk “Tanggal Benih Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya