Discounts.php 656 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Discounts extends Model
  5. {
  6. protected $table = "tb_dm_discounts";
  7. protected $guarded = [];
  8. public function discount_outlets(){
  9. return $this->hasMany('App\Models\DiscountOutlets','discount_id','id')->orderBy('created_at','DESC');
  10. }
  11. public function discount_items(){
  12. return $this->hasMany('App\Models\DiscountItems','discount_id','id')->orderBy('created_at','DESC');
  13. }
  14. public function getDiscountNamesAttribute(){
  15. return $this->attributes['discount_names'] = array('ar'=>$this->discount_name_arabic,'en'=>$this->discount_name);
  16. }
  17. }