BaseProductImage.php 597 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. class BaseProductImage extends Model
  6. {
  7. use HasDateTimeFormatter;
  8. protected $table = 'base_product_image';
  9. protected $casts = [
  10. 'created_at' => 'datetime:Y-m-d H:i:s',
  11. 'updated_at' => 'datetime:Y-m-d H:i:s',
  12. ];
  13. protected $fillable = [
  14. 'image_url',
  15. 'product_id',
  16. 'order',
  17. ];
  18. // 反向关联,属于某个产品
  19. public function product()
  20. {
  21. return $this->belongsTo(BaseProduct::class, 'id');
  22. }
  23. }