mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use MongoDB\Laravel\Auth\User as Authenticatable;
|
|
use MongoDB\Laravel\Relations\HasMany;
|
|
use Overtrue\LaravelFavorite\Traits\Favoriter;
|
|
use Spatie\Searchable\Searchable;
|
|
use Spatie\Searchable\SearchResult;
|
|
|
|
class User extends Authenticatable implements Searchable
|
|
{
|
|
protected $connection = 'mongodb';
|
|
protected $table = 'users';
|
|
|
|
use HasApiTokens, HasFactory, Notifiable, Favoriter;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
public function posts(): HasMany
|
|
{
|
|
return $this->hasMany(Post::class);
|
|
}
|
|
|
|
public function comments(): HasMany
|
|
{
|
|
return $this->hasMany(Comment::class);
|
|
}
|
|
|
|
public function getSearchResult(): SearchResult
|
|
{
|
|
$url = url("/profiles/$this->id");
|
|
return new SearchResult(
|
|
$this,
|
|
$this->name,
|
|
$url
|
|
);
|
|
}
|
|
}
|