Answers for "laravel eloquent remove then attach"

PHP
2

laravel eloquent remove from db

$res=User::where('id',$id)->delete();
Posted by: Guest on November-05-2020
2

laravel delete relationship data

class User extends Eloquent
{
    public function photos()
    {
        return $this->has_many('Photo');
    }

    // this is a recommended way to declare event handlers
    public static function boot() {
        parent::boot();

        static::deleting(function($user) { // before delete() method call this
             $user->photos()->delete();
             // do the rest of the cleanup...
        });
    }
}
Posted by: Guest on November-08-2020
2

laravel eloquent remove from db

public function destroy($id){

  $res=User::find($id)->delete();
  if ($res){
    $data=[
    'status'=>'1',
    'msg'=>'success'
  ];
  }else{
    $data=[
    'status'=>'0',
    'msg'=>'fail'
  ];
  return response()->json($data);
Posted by: Guest on November-05-2020
0

laravel mass update relationship

$channel->videos()->update(['visibility' => true]);
Posted by: Guest on April-16-2020

Code answers related to "laravel eloquent remove then attach"

Browse Popular Code Answers by Language