mercredi 29 novembre 2017

Update row with data from another row in the same table in Laravel

I am trying to update one line with another in my database. I can not find a way to do this.

I have a parent line and a child line. I want to update the PARENT activity with the CHILD activity (draft).

In my controller :

public function update(UpdateRequest $request)
  {
    if (Auth::user()->hasRole('Administrateur'))
    {
        // DRAFT ACTIVITY
        $id = $request->id;
        $activity  = Activity::find($id);

        // PARENT ACTIVITY
        $parent_id = $activity->parent_id;
        $parent_activity = Activity::find($parent_id);

        DB::table('activities')->???

      }
  }

Can you help me ? Thank you very much !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire