mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-11-06 00:50:36 +03:00
Updated uses of user ID to nullify on delete. Added testing to cover deletion of user relations. Added model factories to support changes and potential other tests. Cleans existing ID references in the DB via migration.
37 lines
758 B
PHP
37 lines
758 B
PHP
<?php
|
|
|
|
namespace BookStack\Access;
|
|
|
|
use BookStack\Activity\Models\Loggable;
|
|
use BookStack\App\Model;
|
|
use BookStack\Users\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property string $driver
|
|
* @property User $user
|
|
*/
|
|
class SocialAccount extends Model implements Loggable
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['user_id', 'driver', 'driver_id'];
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function logDescriptor(): string
|
|
{
|
|
return "{$this->driver}; {$this->user->logDescriptor()}";
|
|
}
|
|
}
|