Answers for "laravel remove relation from collection"

SQL
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
0

sql delete from with relation

# your select statement acctually works (and I don't know wich is your statement...).
# You must replace only
SELECT ...
# with
DELETE [table name or alias]
# and leave everything else the same.

# e.g:
DELETE cu FROM CustomUser cu 
left join RoleMapping on cu.id = RoleMapping.principalId 
WHERE RoleMapping.roleId = 1;
Posted by: Guest on August-02-2021

Code answers related to "laravel remove relation from collection"

Code answers related to "SQL"

Browse Popular Code Answers by Language