[英]Laravel seeding preg_replace(): error
我想知道是否有人可以帮助我。
我在使用种子器在laravel中播种数据库时遇到麻烦,它一直在解决此错误:
preg_replace(): Parameter mismatch, pattern is a string while replacement is an array
当运行php artisan db:seed时
有问题的播种器是:GroupTableSeeder.php,文件中的代码是:
<?php
class GroupTableSeeder extends Seeder {
public function run()
{
DB::table('groups')->truncate();
$permissions = array( 'system' => 1, );
$group = array(
array(
'name' => 'agency',
'permissions' => $permissions,
'created_at' => new DateTime,
'updated_at' => new DateTime
),
);
DB::table('groups')->insert($group);
}
}
在DatabaseSeeder.php中,我具有:
public function run()
{
Eloquent::unguard();
$this->call('GroupTableSeeder');
$this->command->info('Group table seeded!');
}
我正在尝试使用当前正在使用https://cartalyst.com/manual/sentry#groups的用户角色填充Groups表
任何帮助将非常感激。
克里斯,干杯
找到答案,我需要这样做:
Sentry::getGroupProvider()->create(array(
'name' => 'Agency',
'permissions' => array('admin' => 1),
));
代替:
$permissions = array( 'system' => 1, );
$group = array(
array(
'name' => 'agency',
'permissions' => $permissions,
'created_at' => new DateTime,
'updated_at' => new DateTime
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.