vendredi 22 février 2019

update two tables using one function in laravel

Hi everyone hope guys you are fine. i'm building an app using laravel 5.7 and vuejs2. i have two tables : departments an users. a user can be a chief of a department. anyway, i made the relationship between the modals... what i want is when i create a new department , the type of the chief will be changed on the users table to 'chief' DepartmentController :

public function store(Request $request)
{
    $this->validate($request,[
        'name'=>'string|required|max:191',
        'bio'=>'string|required',
        'user_id'=>'integer|required|unique:departements'
        ]);

    return Department::create([

        'name'=>$request['name'],
        'user_id'=>$request['user_id'],
        'bio'=>$request['bio']
         ]);

}

thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire