GrowthValueCustomer.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Longyi\RewardPoints\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Webkul\Customer\Models\Customer;
  5. class GrowthValueCustomer extends Model
  6. {
  7. protected $table = 'mw_growth_value_customer';
  8. protected $fillable = [
  9. 'customer_id',
  10. 'growth_value',
  11. 'growth_level',
  12. 'first_order_completed_at',
  13. 'level_updated_at',
  14. 'growth_value_expires_at',
  15. ];
  16. protected $casts = [
  17. 'customer_id' => 'integer',
  18. 'growth_value' => 'integer',
  19. 'first_order_completed_at' => 'datetime',
  20. 'level_updated_at' => 'datetime',
  21. 'growth_value_expires_at' => 'datetime',
  22. ];
  23. public function customer()
  24. {
  25. return $this->belongsTo(Customer::class, 'customer_id');
  26. }
  27. public function history()
  28. {
  29. return $this->hasMany(GrowthValueHistory::class, 'customer_id', 'customer_id');
  30. }
  31. public function levelConfig()
  32. {
  33. return $this->hasOne(GrowthValueLevel::class, 'level_code', 'growth_level');
  34. }
  35. }