restriction text implementation for the frontend

This commit is contained in:
Čarodej
2022-06-14 10:31:55 +02:00
parent ebf1b16aa5
commit aaea435eb0
7 changed files with 18 additions and 16 deletions
+9 -4
View File
@@ -3,6 +3,7 @@ namespace App\Users\Models;
use ByteUnits\Metric;
use Illuminate\Support\Str;
use BadMethodCallException;
use Domain\Files\Models\File;
use Domain\Folders\Models\Folder;
use Laravel\Sanctum\HasApiTokens;
@@ -196,10 +197,14 @@ class User extends Authenticatable implements MustVerifyEmail
public function __call($method, $parameters)
{
if (str_starts_with($method, 'can') || str_starts_with($method, 'get')) {
return resolve(RestrictionsManager::class)
->driver()
->$method($this, ...$parameters);
try {
if (str_starts_with($method, 'can') || str_starts_with($method, 'get')) {
return resolve(RestrictionsManager::class)
->driver()
->$method($this, ...$parameters);
}
} catch (BadMethodCallException $e) {
return parent::__call($method, $parameters);
}
return parent::__call($method, $parameters);
@@ -70,13 +70,13 @@ class MeteredBillingRestrictionsEngine implements RestrictionsEngine
{
if ($this->getDunningSequenceCount($user) === 3) {
return match ($user->dunning->type) {
'limit_usage_in_new_accounts' => 'Please make your first payment.',
'usage_bigger_than_balance' => 'Please increase your account balance.',
'limit_usage_in_new_accounts' => 'Please make your first payment to cover your usage.',
'usage_bigger_than_balance' => 'Please increase your account balance higher than your monthly usage.',
};
}
if (! $this->checkFailedPayments($user)) {
return 'Please update your credit card.';
return 'Please update your credit card to pay your usage.';
}
return null;