Attribute.php 723 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Packages\Product\Models;
  3. use Illuminate\Database\Eloquent\SoftDeletes;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Attribute extends Model
  6. {
  7. use SoftDeletes;
  8. protected $fillable=['title', 'key', 'use_in_veriation'];
  9. public function products()
  10. {
  11. return $this->morphedByMany(Product::class, 'attributable');
  12. }
  13. public function getUseInVeriationAttribute($value)
  14. {
  15. switch ($value) {
  16. case 0:
  17. $UseInVeriation = 'خیر';
  18. break;
  19. case 1:
  20. $UseInVeriation = 'بله';
  21. break;
  22. default:
  23. $UseInVeriation = '';
  24. }
  25. return $UseInVeriation ;
  26. }
  27. }