1. DatabaseSeeder.php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call(MarketsTableSeeder::class);
}
}
2. MarketsTableSeeder.php
use Illuminate\Database\Seeder;
use App\Market;
class MarketsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
App\Market::create(['name' => 'Direct Sales', 'val'=>20]);
}
}
3. You need App\Market model as well
4. run command "php artisan db:seed" on command prompt
5. I having class compile error , try 'composer dump-autoload" and "php artisan clear-compiled"
https://laracasts.com/discuss/channels/general-discussion/php-artisan-dbseed?page=1
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call(MarketsTableSeeder::class);
}
}
2. MarketsTableSeeder.php
use Illuminate\Database\Seeder;
use App\Market;
class MarketsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
App\Market::create(['name' => 'Direct Sales', 'val'=>20]);
}
}
3. You need App\Market model as well
4. run command "php artisan db:seed" on command prompt
5. I having class compile error , try 'composer dump-autoload" and "php artisan clear-compiled"
https://laracasts.com/discuss/channels/general-discussion/php-artisan-dbseed?page=1
No comments:
Post a Comment