2014-09-26 34 views
0

我有點卡在質量分配。我有一個輸入字段(日期選擇器)需要修改(應用strtotime函數),然後將其插入數據庫。Laravel 4雄辯的質量分配 - 修改輸入

在使用質量分配時有沒有辦法做到這一點?

class Customer extends Ardent { 
    protected $table = 'customers'; 
    public $autoPurgeRedundantAttributes = true; 
    public $autoHydrateEntityFromInput = true; 
    public $forceEntityHydrationFromInput = true; 


    protected $fillable = array(

     'email', 
    ); 
} 
+0

是的,它是可能的,但請告訴我們你做了什麼至今,所以我們有一個起點。 – 2014-09-26 01:09:14

+0

那麼,不知道我應該告訴你什麼。這是一個簡單的雄辯模型,沒有太多的展示。我雖然更新了我的問題。謝謝 – Michael 2014-09-26 01:13:14

+0

你打算在哪裏修改該輸入字段?在你的控制器?所以告訴我們你的控制器以及你如何在數據庫中插入東西,你使用的是create()嗎?可能,但我們怎麼能確定?問題的方式太廣泛了。 – 2014-09-26 01:16:05

回答

0

如果你只需要改變輸入,你可以這樣做:

$input = Input::all(); 

$input['date'] = strtotime($input['date']); 

Input::replace($input);