2016-11-22 76 views
0

我有一個文件在我的config文件夾消息作爲將數據保存到數據庫(Laravel 5.3)

'msg_log' => [ 
     'created' => 'created successfully', 
     'not_created' => 'not created', 

] 我在數據庫表中作爲消息有兩個領域如果創建或如果沒有創建等領域notcreated應該到哪裏創建是味精應該在控制器

去消息 我這怎麼能保存到我的郵件表從存儲方法
public function store(Request $request) 
{ 


    $data['email']   = $request->input('email'); 
    $data['password']   = bcrypt($request->input('password')); 

    $user = User::create($data); 
    if($user->id) { 
     // If Created Here 
    }else{ 
     // Not created 

    } 

請告訴我該怎麼做,如果別人來保存味精在消息表 感謝

+0

什麼是你的配置文件名?可能[this](https://laracasts.com/discuss/channels/general-discussion/ho-to-access-config-variables-in-laravel-5?page=1)可以幫助你。 – Tiger

+0

我馬上得到消息,但不知道如何獲得''創建'=>'創建成功','在上面創建存儲在數據庫意味着已成功創建沒有得到創建關鍵字 –

+0

配置文件名是messages.php –

回答

0

你應該試試這個

public function store(Request $request) 
{ 
    $data['email']   = $request->input('email'); 
    $data['password']  = bcrypt($request->input('password')); 
    if(User::create($data)) { 
    // If Created Here 
    }else{ 
    // Not created 
    } 
} 
+0

不起作用親愛的 –

+0

什麼錯誤顯示 –

+0

完整性約束問題..但我解決自己的方式不同謝謝 –