This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
@@ -30,6 +31,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
* @property WorkspaceType $type
|
||||
* @property bool $personal_workspace
|
||||
* @property bool $lifetime_access
|
||||
* @property int|null $plan_id
|
||||
* @property string|null $stripe_id
|
||||
* @property string|null $pm_type
|
||||
* @property string|null $pm_last_four
|
||||
@@ -37,7 +39,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*/
|
||||
#[Fillable(['name', 'type', 'personal_workspace', 'lifetime_access'])]
|
||||
#[Fillable(['name', 'type', 'personal_workspace', 'lifetime_access', 'plan_id'])]
|
||||
#[Hidden(['stripe_id'])]
|
||||
class Organization extends Model
|
||||
{
|
||||
@@ -69,6 +71,14 @@ class Organization extends Model
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Plan, $this>
|
||||
*/
|
||||
public function plan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plan::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Folder, $this>
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\WorkspaceType;
|
||||
use Database\Factories\PlanFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* A plan is a tier of access: it decides what kind of workspace a subscriber
|
||||
* gets, how many members it may hold, and how many folders and notes its
|
||||
* members may create. Every plan is editable by a site administrator, so the
|
||||
* limits live in the database rather than in configuration.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $key
|
||||
* @property string $name
|
||||
* @property WorkspaceType $workspace_type
|
||||
* @property string|null $stripe_price
|
||||
* @property string $interval
|
||||
* @property int $amount
|
||||
* @property int|null $seat_limit
|
||||
* @property int|null $max_folders
|
||||
* @property int|null $max_folder_depth
|
||||
* @property int|null $max_notes_per_folder
|
||||
* @property int|null $note_chars
|
||||
* @property int $sort_order
|
||||
* @property bool $is_active
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*/
|
||||
#[Fillable([
|
||||
'key',
|
||||
'name',
|
||||
'workspace_type',
|
||||
'stripe_price',
|
||||
'interval',
|
||||
'amount',
|
||||
'seat_limit',
|
||||
'max_folders',
|
||||
'max_folder_depth',
|
||||
'max_notes_per_folder',
|
||||
'note_chars',
|
||||
'sort_order',
|
||||
'is_active',
|
||||
])]
|
||||
class Plan extends Model
|
||||
{
|
||||
/** @use HasFactory<PlanFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'workspace_type' => WorkspaceType::class,
|
||||
'amount' => 'integer',
|
||||
'seat_limit' => 'integer',
|
||||
'max_folders' => 'integer',
|
||||
'max_folder_depth' => 'integer',
|
||||
'max_notes_per_folder' => 'integer',
|
||||
'note_chars' => 'integer',
|
||||
'sort_order' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Organization, $this>
|
||||
*/
|
||||
public function organizations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Organization::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the plan can be sold, that is, it has a Stripe price.
|
||||
*/
|
||||
public function isPurchasable(): bool
|
||||
{
|
||||
return is_string($this->stripe_price) && $this->stripe_price !== '';
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@ use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
* @property Carbon|null $two_factor_confirmed_at
|
||||
* @property string|null $remember_token
|
||||
* @property bool $is_admin
|
||||
* @property int $notes_limit
|
||||
* @property int|null $notes_limit
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user