-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migrations, factories and models
- Loading branch information
1 parent
6e42c98
commit 3a254ee
Showing
19 changed files
with
801 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class DnsSetting extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'dns_settings'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'domain_id', | ||
'record_type', | ||
'name', | ||
'value', | ||
'ttl', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = [ | ||
'ttl' => 'integer', | ||
]; | ||
|
||
/** | ||
* Get the domain that owns the DNS setting. | ||
*/ | ||
public function domain() | ||
{ | ||
return $this->belongsTo(Domain::class); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Domain extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'domains'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', | ||
'domain_name', | ||
'registration_date', | ||
'expiration_date', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = [ | ||
'registration_date' => 'date', | ||
'expiration_date' => 'date', | ||
]; | ||
|
||
/** | ||
* Get the user that owns the domain. | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
/** | ||
* Get the email accounts for the domain. | ||
*/ | ||
public function emailAccounts() | ||
{ | ||
return $this->hasMany(EmailAccount::class); | ||
} | ||
|
||
/** | ||
* Get the DNS settings for the domain. | ||
*/ | ||
public function dnsSettings() | ||
{ | ||
return $this->hasMany(DnsSetting::class); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class EmailAccount extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'email_accounts'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', | ||
'domain_id', | ||
'email_address', | ||
'password', | ||
'quota', | ||
]; | ||
|
||
/** | ||
* Get the user that owns the email account. | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
/** | ||
* Get the domain that owns the email account. | ||
*/ | ||
public function domain() | ||
{ | ||
return $this->belongsTo(Domain::class); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class HostingPlan extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'hosting_plans'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'name', | ||
'description', | ||
'disk_space', | ||
'bandwidth', | ||
'price', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = [ | ||
'price' => 'decimal:2', | ||
]; | ||
|
||
/** | ||
* The attributes that should be hidden for arrays. | ||
* | ||
* @var array | ||
*/ | ||
protected $hidden = [ | ||
'created_at', | ||
'updated_at', | ||
]; | ||
|
||
public function userHostingPlans() | ||
{ | ||
return $this->hasMany(UserHostingPlan::class); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class ResourceUsage extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'resource_usage'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', | ||
'disk_usage', | ||
'bandwidth_usage', | ||
'month', | ||
'year', | ||
]; | ||
|
||
/** | ||
* Get the user that owns the resource usage. | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class UserHostingPlan extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'user_hosting_plans'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', | ||
'hosting_plan_id', | ||
'start_date', | ||
'end_date', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = [ | ||
'start_date' => 'date', | ||
'end_date' => 'date', | ||
]; | ||
|
||
/** | ||
* Get the user that owns the hosting plan. | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
/** | ||
* Get the hosting plan associated with the user. | ||
*/ | ||
public function hostingPlan() | ||
{ | ||
return $this->belongsTo(HostingPlan::class); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\DnsSetting; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class DnsSettingFactory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = DnsSetting::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
$recordTypes = ['A', 'CNAME', 'MX', 'TXT']; | ||
|
||
return [ | ||
'domain_id' => function () { | ||
return \App\Models\Domain::factory()->create()->id; | ||
}, | ||
'record_type' => $this->faker->randomElement($recordTypes), | ||
'name' => $this->faker->domainName, | ||
'value' => $this->faker->ipv4, | ||
'ttl' => $this->faker->numberBetween(300, 86400), // TTL between 300 seconds (5 minutes) and 86400 seconds (24 hours) | ||
'created_at' => now(), | ||
'updated_at' => now(), | ||
]; | ||
} | ||
} | ||
|
Oops, something went wrong.