-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Review model with relationships and busi
- Loading branch information
1 parent
fb84d0c
commit cb05ba0
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Review extends Model | ||
{ | ||
protected $table = 'reviews'; | ||
|
||
protected $fillable = [ | ||
'user_id', 'product_id', 'rating', 'review', 'approved' | ||
]; | ||
|
||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
public function product() | ||
{ | ||
return $this->belongsTo(Product::class); | ||
} | ||
|
||
public function approve() | ||
{ | ||
$this->approved = true; | ||
$this->save(); | ||
} | ||
|
||
public function reject() | ||
{ | ||
$this->approved = false; | ||
$this->save(); | ||
} | ||
} |