Changeset View
Changeset View
Standalone View
Standalone View
src/app/Handlers/Storage.php
<?php | <?php | ||||
namespace App\Handlers; | namespace App\Handlers; | ||||
use App\Quota; | class Storage extends \App\Handlers\Base | ||||
use App\Sku; | |||||
use App\User; | |||||
class Storage | |||||
{ | |||||
public static function createDefaultEntitleable(User $user) | |||||
{ | { | ||||
$quota = new Quota(); | |||||
$quota->user_id = $user->id; | |||||
$quota->save(); | |||||
return $quota->id; | |||||
} | |||||
public static function entitleableClass() | public static function entitleableClass() | ||||
{ | { | ||||
return Quota::class; | return null; | ||||
} | } | ||||
public static function preReq($entitlement, $user) | public static function preReq($entitlement, $object) | ||||
{ | { | ||||
if (!Sku::find($entitlement->sku_id)->active) { | // TODO: The storage can not be modified to below what is already consumed. | ||||
\Log::error("Sku not active"); | |||||
return false; | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
} | } |