You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.1 KiB
54 lines
2.1 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* App\Models\Comment
|
|
*
|
|
* @property int $id
|
|
* @property int $order_id
|
|
* @property int $order_detail_id
|
|
* @property int $product_id
|
|
* @property int $user_id
|
|
* @property string $content 评论内容
|
|
* @property int $score
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property-read \App\Models\Product $product
|
|
* @property-read \App\Models\User $user
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereContent($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereOrderDetailId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereOrderId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereProductId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereScore($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereUserId($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Comment extends Model
|
|
{
|
|
protected $fillable = [
|
|
'score', 'user_id', 'product_id', 'order_id', 'content'
|
|
];
|
|
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class)->withDefault(function () {
|
|
|
|
return new User(['avatar' => 'avatars/default/' . array_random(User::DEFAULT_AVATARS)]);
|
|
});
|
|
}
|
|
}
|