Laravel - Serialization - Appending At Run Time

At runtime, you may instruct a model instance to append additional attributes using the append method. Or, you may use the setAppends method to override the entire array of appended properties for a given model instance:

    
    return $user->append('is_admin')->toArray();
    
    return $user->setAppends(['is_admin'])->toArray();