DistProductImage.php 628 B

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