BaseProductImage.php 572 B

1234567891011121314151617181920212223242526
  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. // 反向关联,属于某个产品
  17. public function product()
  18. {
  19. return $this->belongsTo(BaseProduct::class, 'id');
  20. }
  21. }