Skip to content

Commit

Permalink
Merge pull request #20 from liberu-genealogy/sweep/allow_one_dockerco…
Browse files Browse the repository at this point in the history
…mposeryml_instance_for

Sweep: Limit free users to one domain and add hosting plan to User model
  • Loading branch information
curtisdelicata authored Jun 16, 2024
2 parents 278ae52 + 64c115b commit 8069b17
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 8069b17

Please sign in to comment.