generated from Flycro/laravel-nuxt
feat: Multiple Systems
This commit is contained in:
34
app/Models/BookRecommendation.php
Normal file
34
app/Models/BookRecommendation.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BookRecommendation extends Model
|
||||
{
|
||||
protected $table = 'book_recommendations';
|
||||
|
||||
protected $fillable = [
|
||||
'book_name',
|
||||
'author',
|
||||
'description',
|
||||
'isbn',
|
||||
'pages',
|
||||
'recommended_by',
|
||||
'cover_image',
|
||||
'status',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the user that recommended the book.
|
||||
*/
|
||||
public function recommender()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'recommended_by');
|
||||
}
|
||||
|
||||
public function votes()
|
||||
{
|
||||
return $this->hasMany(Vote::class);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
'email',
|
||||
'avatar',
|
||||
'password',
|
||||
'total_votes',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -57,6 +58,11 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
return $this->hasMany(UserProvider::class);
|
||||
}
|
||||
|
||||
public function votes()
|
||||
{
|
||||
return $this->hasMany(Vote::class);
|
||||
}
|
||||
|
||||
public function mustVerifyEmail(): bool
|
||||
{
|
||||
return $this instanceof MustVerifyEmail && !$this->hasVerifiedEmail();
|
||||
|
||||
26
app/Models/Vote.php
Normal file
26
app/Models/Vote.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Vote extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'book_recommendation_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function bookRecommendation()
|
||||
{
|
||||
return $this->belongsTo(BookRecommendation::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user