Skip to content

Commit

Permalink
feat: Add Review model with relationships and busi
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 11, 2024
1 parent fb84d0c commit cb05ba0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions app/Models/Review.php
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();
}
}

0 comments on commit cb05ba0

Please sign in to comment.