Support the ongoing development of Laravel.io →
posted 8 years ago
Database
Last updated 1 year ago.
0

You can use laravel included package called "seed"

http://laravel.com/docs/5.0/migrations#database-seeding

0

I've tried to use it but it does not work this is DatabaseSeeder.php file

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use DB;

class DatabaseSeeder extends Seeder {

	/**
	 * Run the database seeds.
	 *
	 * @return void
	 */
	public function run()
	{
		Model::unguard();

		$this->call('AdminSeeder');
	}

}

and this is AdminSeeder.php

<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use DB;
class AdminSeeder extends Seeder {

	public function run(){
		Model::unguard();
		$user = ['name' => 'name','email' => '[email protected]','password' => bcrypt('123456')];
		$db = DB::table('users')->insert($user);
	}

}

when I type

php artisan db:seed

it returns nothing

Last updated 8 years ago.
0
Solution

there is a problem with my path in sublime and terminal I fixed it and it's solved :D

0

You should try to use the factory method of 5.1 or testdummies package in 5.0 to create multiple fake users (which in turns use fakery package)

*Caveat: I couldnt get 5.1 to run factory method properly

0

Sign in to participate in this thread!

Eventy

Your banner here too?

aanmtn aanmtn Joined 13 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.