mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
update
This commit is contained in:
parent
afc1fb10bc
commit
8004c8d69e
12 changed files with 320 additions and 5 deletions
24
app/Models/Comment.php
Normal file
24
app/Models/Comment.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use MongoDB\Laravel\Eloquent\Model;
|
||||
use MongoDB\Laravel\Eloquent\SoftDeletes;
|
||||
use MongoDB\Laravel\Relations\BelongsTo;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [ 'message' ];
|
||||
|
||||
public function post(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Post::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,12 +5,16 @@ namespace App\Models;
|
|||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use MongoDB\Laravel\Eloquent\Model;
|
||||
use MongoDB\Laravel\Eloquent\SoftDeletes;
|
||||
use MongoDB\Laravel\Relations\BelongsTo;
|
||||
use MongoDB\Laravel\Relations\BelongsToMany;
|
||||
use MongoDB\Laravel\Relations\HasMany;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [ 'rating', 'extension', 'featured' ];
|
||||
|
||||
public function user(): BelongsTo
|
||||
|
|
@ -23,6 +27,11 @@ class Post extends Model
|
|||
return $this->belongsToMany(Tag::class);
|
||||
}
|
||||
|
||||
public function comments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class);
|
||||
}
|
||||
|
||||
protected function toBase64(string $path): string
|
||||
{
|
||||
$ext = $this->extension;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ class User extends Authenticatable
|
|||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
|
@ -39,4 +38,9 @@ class User extends Authenticatable
|
|||
{
|
||||
return $this->hasMany(Post::class);
|
||||
}
|
||||
|
||||
public function comments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue