Файл: app/Models/CardUserModel.php
Строк: 27
<?php
namespace AppModels;
use IlluminateDatabaseEloquentModel;
use AppServicesServices;
class CardUserModel extends Model
{
protected $table = 'cards_user';
protected $fillable = ['user', 'card', 'learn_time', 'status', 'upgrade_level'];
protected $appends = [
'total_power'
];
public function getCardInfo()
{
return $this->hasOne(AppModelsCardModel::class, 'id', 'card');
}
public function getTotalPowerAttribute()
{
$stat = round($this->getCardInfo->health+Services::getUpgradeBonus($this->getCardInfo->health, $this->upgrade_level))+round($this->getCardInfo->armor+Services::getUpgradeBonus($this->getCardInfo->armor, $this->upgrade_level))+round($this->getCardInfo->max_attack+Services::getUpgradeBonus($this->getCardInfo->max_attack, $this->upgrade_level));
return $stat;
}
}