word-salad/app/Models/Author.php

40 lines
962 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Author extends Model
{
use HasFactory;
/** The name of the database table storing this Model's records. */
protected $table = 'authors';
/** The attributes on the Model that can be mass-assigned */
protected $fillable = [
'display_name',
'profile_image_url',
'user_id',
'biography',
'primary_link',
'secondary_link',
'mastodon_handle',
];
/** The application-level User account of this writer */
public function user(): HasOne
{
return $this->hasOne(User::class);
}
/** All the Articles this person has written */
public function articles(): HasMany
{
return $this->hasMany(Article::class);
}
}