Skip to content

Commit

Permalink
Add hosting_plan to User, limit free users to 1 do
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Jun 16, 2024
1 parent 278ae52 commit 64c115b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class CreateDomain extends CreateRecord

protected function handleRecordCreation(array $data): Domain
{
$user = auth()->user();

if ($user->hosting_plan === 'free' && $user->domains()->count() >= 1) {
throw new \Exception('Free users are limited to one domain.');
}

$domain = static::getModel()::create($data);

$composeContent = $this->generateDockerComposeContent($data);
Expand Down
10 changes: 10 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ class User extends Authenticatable
'name',
'email',
'password',
'hosting_plan',
];

/**
* The model's default values for attributes.
*
* @var array<string, mixed>
*/
protected $attributes = [
'hosting_plan' => 'free',
];

/**
Expand Down

0 comments on commit 64c115b

Please sign in to comment.