当我将数据集存储在Laravel中时,有时会出现此错误,但尚未找到解决方案。Laravel“不允许”关闭“的序列化”
public function store()
{
$data = Input::all();
$validator = array('first_name' =>'required', 'last_name' => 'required', 'email' => 'email|required_without:phone', 'phone' => 'numeric|size:10|required_without:email', 'address' => 'required');
$validate = Validator::make($data, $validator);
if($validate->fails()){
return Redirect::back()->with('message', $validate);
} else {
$customer = new Customer;
foreach (Input::all() as $field => $value) {
if($field == '_token') continue;
$customer->$field = $value;
}
$customer->save();
return View::make('admin/customers/show')->withcustomer($customer);
}
}
是什么原因造成这种序列化错误:
Serialization of 'Closure' is not allowed
Open: ./vendor/laravel/framework/src/Illuminate/Session/Store.php
*/
public function save()
{
$this->addBagDataToSession();
$this->ageFlashData();
$this->handler->write($this->getId(), serialize($this->attributes));
$this->started = false;
这里发生错误时被调用的函数?
实际上'返回View :: make('admin/customers/show') - > with($ customer);'不起作用,'OP'使用'withcustomer',但它应该是'withCustomer',所以$ customer变量将在'view'中可用,它是'dynamic method'。 – 2014-10-05 16:46:20
很高兴知道。我修复了我错过的一些小问题。我之前没有看到过'with'的用法,所以我有点迷路。 – 2014-10-05 16:48:06