'commission_shop', 2 => 'commission_payline', 3 => 'credit_added', 4 => 'commission', 5 => 'commission_growth_bonus', ]; public static $statusColors = [ 0 => 'warning', 1 => 'success', 2 => 'secondary', 3 => 'warning', 4 => 'info', 5 => 'secondary', 10 => 'danger', ]; protected $table = 'user_credit_items'; protected $casts = [ 'user_id' => 'int', 'user_credit_id' => 'int', 'user_business_id' => 'int', 'credit' => 'float', 'status' => 'int', 'from_month' => 'int', 'from_year' => 'int', 'paid' => 'bool' ]; protected $fillable = [ 'user_id', 'user_credit_id', 'user_business_id', 'credit', 'message', 'status', 'from_month', 'from_year', 'paid' ]; public function user_credit() { return $this->belongsTo(UserCredit::class); } public function user() { return $this->belongsTo(User::class); } public function deleteTime(){ $time = '+100 min'; if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){ return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time)); } return false; } public function getStatusType(){ return isset(self::$statusTypes[$this->status]) ? __('payment.'.self::$statusTypes[$this->status]) : ""; } public function getStatusColor(){ return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default"; } public function getTransMessage(){ $ret = ""; if(strpos($this->message, '#')){ $em = explode("#", $this->message); if(isset($em[0])){ //Provision $ret .= trans($em[0])." "; } if(isset($em[1])){ //month $ret .= HTMLHelper::getMonth($em[1])." "; } if(isset($em[2])){ //year $ret .= $em[2]; } } return $ret; } }