【发布时间】:2014-07-28 18:24:18
【问题描述】:
我想知道是否有人可以帮助我。
我在使用播种机在 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 表
任何帮助将不胜感激。
干杯, 克里斯
【问题讨论】:
-
我不确定这是否是问题所在,但看起来您的
$group中有一个不必要的数组。尝试删除其中一个,看看是否有帮助。
标签: laravel laravel-4 cartalyst-sentry