dpcwz210393 2018-08-25 15:36
浏览 91
已采纳

Laravel错误:只应通过引用返回变量引用

I am working on a web app with php laravel framework. I'm also using framwork eloquent.

When i create a new "user" and i send it to my database the error with $myValue->save();

This is the error:

"at HandleExceptions->handleError(8, 'Only variable references should be returned by reference', 
'C:\\wamp64\\www\\project\\Fiq-spsslsj\\app\\Http\\Controllers\\DossierController.php', 97, array('request' => object(Request), 'employe' => object(employe))) 
in DossierController.php line 97"

I've seen some similar problem but they are not quite really usefull (the problem in the other topics talk about code ingniter and common.php).

public function ajouter(Request $request){
    $employe = new employe;
    $employe->No_Employe = $request->input('No_Employe');
    $employe->Nom = $request->input('Nom');
    $employe->Prenom = $request->input('Prenom');
    $employe->Email = $request->input('Email');
    $employe->Adresse = $request->input('Adresse');
    $employe->Date_Naissance = $request->input('Date_Naissance');
    $employe->Titre_Emploi = $request->input('Titre_Emploi');
    $employe->Telephone = $request->input('Telephone');
    $employe->Annee_Embauche = $request->input('Annee_Embauche');
    $employe->Present_Travail = $request->input('optTrav');
    $employe->Sexe = $request->input('optSexe');
    $employe->Fumeur = $request->input('optFum');
    $employe->Langue = $request->input('Langue');

    if (DB::table('liste_ville')->where('Nom_Ville','=',$request->input('Ville'))->get() != null) 
    {
        $employe->Fk_Id_Ville = DB::table('liste_ville')->where('Nom_Ville','=',$request->input('Ville'))->value('Id_Ville');
    }
    else
    {   
        $newVille = ucfirst($request->input('Ville'));
        DB::table('liste_ville')->insertGetId(['Nom_Ville' => $newVille]);
        $MoreVille = DB::table('liste_ville')->get();
        foreach ($MoreVille as $key => $v) 
        {
            if(strtolower($request->input('Ville')) === strtolower($v->Nom_Ville)){
                $employe->Fk_Id_Ville = $v->Id_Ville;
                break;
            }
        }

    }
    $employe->Code_Postal = $request->input('Code_Postal');
    $employe->Actif = $request->input('optActif');

    if (DB::table('provinces')->where('Nom_Province','=',$request->input('Province'))->get() != null) {
        $employe->Fk_Id_Province =DB::table('provinces')->where('Nom_Province','=',$request->input('Province'))->value('Id_Province');
    }
    else
    {   
        $newProv = ucfirst($request->input('Province'));
        DB::table('provinces')->insertGetId(['Nom_Province' => $newProv]);
        foreach ($provinces as $key => $p) 
        {
            if(strtolower($request->input('Province')) === strtolower($p->Nom_Province)){
                $employe->Fk_Id_Province = $p->Id_Province;
                break;
            }
        }
    }
    $employe->save();
    return redirect('/dossiers');
}

The code above is the code in my controller. I hope you'll be able to help me.

  • 写回答

1条回答 默认 最新

  • dsa45664 2018-08-27 09:34
    关注

    Try this in your controller

    return redirect()->to('/dossiers');

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题
  • ¥15 python点云生成mesh精度不够怎么办
  • ¥15 QT C++ 鼠标键盘通信