Product.php 444 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Models;
  3. class Product extends BaseModel
  4. {
  5. protected $fillable = [
  6. 'name', 'belong', 'sort', 'image', 'href', 'txt'
  7. ];
  8. public function getBelongAttribute($value)
  9. {
  10. return $this->belongFormat($value);
  11. }
  12. public function getProductsFromMenuId($menu_id)
  13. {
  14. return $this->where('belong', $menu_id)
  15. ->orderBy('sort')
  16. ->get();
  17. }
  18. }