Closed odyright closed 8 years ago
thanks for your interest now I have updated the seed files try it in this order
php artisan db:seed -class=facultyTableSeeder
php artisan db:seed -class=departmentTableSeeder
php artisan db:seed -class=batchesTableSeeder
php artisan db:seed -class=genderTableSeeder
php artisan db:seed -class=userTableSeeder
php artisan db:seed -class=guardiansTableSeeder
php artisan db:seed -class=studentsTableSeeder
PS: this is app is a work in progress
ok i see but modify the -class
to --class
and i think you forgot that the student and the guardians doesn't exist in seeds folder.
ok now fixed it. by the way I added the student and guardians seeder files earlier
yeah, good but in seeds folder the DatabaseSeeder.php is missing... without it the migration couldn't be reached successfully.
here you are:
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call(batchesTableSeeder::class);
$this->call(studentsTableSeeder::class);
$this->call(guardiansTableSeeder::class);
$this->call(departementTableSeeder::class);
$this->call(facultyTableSeeder::class);
$this->call(genderTableSeeder::class);
$this->call(userTableSeeder::class);
Model::reguard();
}
}
thanks! now I have added the database seeder file
the php artisan db:seed
generated sql error. So i think it would be better to do it individually as you mentionned above.
the error is due to order of seeding the database. now I have modified the seeder file hopefully it will work now
problem with the departmentTableSeeder file
run php artisan migrate:refresh
then use the last seeder files i uploaded php artisan db:seed
[Illuminate\Database\QueryException] SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
testapp.
batches, CONSTRAINT
batches_department_id_foreignFOREIGN KEY (
department_id) REFERENCES
departments
(
id)) (SQL: insert into
batches(
batch_name,
department_id,
updated_at,
created_at) valu es (BE6, 1, 2016-02-27 18:28:23, 2016-02-27 18:28:23))
[PDOException] SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
testapp.
batches, CONSTRAINT
batches_department_id_foreignFOREIGN KEY (
department_id) REFERENCES
departments
(
id))
How to solve it?