First, you do not need to pass id. It will be substituted automatically.
Secondly, the side file, as well as the class, should be called CamelCase in the format.
The file name must match the class name.
Thirdly, if you created the cider manually, execute the command in the console
composer dump-autoload
being in the project folder.
Do not forget to migrate the team
php artisan migrate
To sit the database run the command
php artisan db:seed --class=blog_table_seeder
To your data from your seder hit the database without specifying the class on the command
php artisan db:seed
It is necessary that the folder DatabaseSeedeer.php following content be in the list of servers:
<?php use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { // ΠΠ»Ρ Laravel 5.1 $this->call(blog_table_seeder::class); // ΠΠ»Ρ Laravel 4.2 Π·Π°ΠΌΠ΅Π½ΠΈΡΡ Π½Π° // $this->call('blog_table_seeder'); } }
The insert method does not automatically insert date.
There are two solutions.
The first solution is to insert data in the sider:
<?php use Illuminate\Database\Seeder; class blog_table_seeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { DB::table('blog')->insert([ 'title' => 'ΡΠ°ΠΉΡΠ» Π½ΠΎΠ²ΠΎΡΡΠΈ', 'meta_description' => 'ΠΌΠ΅ΡΠ° ΠΎΠΏΠΈΡΠ°Π½ΠΈΠ΅', 'meta_keywords' => 'ΠΊΠ»ΡΡΠ΅Π²ΠΈΠΊΠΈ', 'image' => 'ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ°', 'description' => 'ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅', 'author' => 'ΠΠ²ΡΠΎΡ', // Π·Π°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ timestamps Π²ΡΡΡΠ½ΡΡ 'created_at' => date('Ymd H:i:s'), 'updated_at' => date('Ymd H:i:s') ]); } }
The second solution is through adding and using the model:
Blog.php
<?php // ΠΠ° ΡΡΠΎΠΌ ΡΡΠ°ΠΏΠ΅ Π±ΡΠ΄ΡΡΠ΅ Π²Π½ΠΈΠΌΠ°ΡΠ΅Π»ΡΠ½Π΅Π΅ Ρ namespace class Blog extends Eloquent { protected $table = 'blog'; }
ΠΠ°Ρ ΡΠΈΠ΄Π΅Ρ.php
<?php use Illuminate\Database\Seeder; // ΠΠ° ΡΡΠΎΠΌ ΡΡΠ°ΠΏΠ΅ Π±ΡΠ΄ΡΡΠ΅ Π²Π½ΠΈΠΌΠ°ΡΠ΅Π»ΡΠ½Π΅Π΅ Ρ namespace class blog_table_seeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { // ΠΌΠ΅ΡΠΎΠ΄ create Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ Π·Π°ΠΏΠΎΠ»Π½ΠΈΡ timestamps Blog::create([ 'title' => 'ΡΠ°ΠΉΡΠ» Π½ΠΎΠ²ΠΎΡΡΠΈ', 'meta_description' => 'ΠΌΠ΅ΡΠ° ΠΎΠΏΠΈΡΠ°Π½ΠΈΠ΅', 'meta_keywords' => 'ΠΊΠ»ΡΡΠ΅Π²ΠΈΠΊΠΈ', 'image' => 'ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ°', 'description' => 'ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅', 'author' => 'ΠΠ²ΡΠΎΡ' ]); } }