Renamed jetstream team to organization

This commit is contained in:
Constantin Graf
2024-01-21 19:52:19 +01:00
parent 6377df1f44
commit 0a8d958ccc
63 changed files with 461 additions and 329 deletions

View File

@@ -14,7 +14,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property string $id
* @property string $name
* @property string $organization_id
* @property-read Team $organization
* @property string $created_at
* @property string $updated_at
* @property-read Organization $organization
*
* @method static ClientFactory factory()
*/
@@ -33,10 +35,10 @@ class Client extends Model
];
/**
* @return BelongsTo<Team, Client>
* @return BelongsTo<Organization, Client>
*/
public function organization(): BelongsTo
{
return $this->belongsTo(Team::class, 'organization_id');
return $this->belongsTo(Organization::class, 'organization_id');
}
}

View File

@@ -7,14 +7,24 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Laravel\Jetstream\Membership as JetstreamMembership;
/**
* @property string $id
* @property string $role
* @property string $organization_id
* @property string $user_id
* @property string $created_at
* @property string $updated_at
* @property-read Organization $organization
* @property-read User $user
*/
class Membership extends JetstreamMembership
{
use HasUuids;
/**
* Indicates if the IDs are auto-incrementing.
* The table associated with the pivot model.
*
* @var bool
* @var string
*/
public $incrementing = true;
protected $table = 'organization_user';
}

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Models;
use Database\Factories\TeamFactory;
use Database\Factories\OrganizationFactory;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -17,10 +17,10 @@ use Laravel\Jetstream\Team as JetstreamTeam;
* @property string $id
* @property User $owner
*
* @method HasMany<TeamInvitation> teamInvitations()
* @method static TeamFactory factory()
* @method HasMany<OrganizationInvitation> teamInvitations()
* @method static OrganizationFactory factory()
*/
class Team extends JetstreamTeam
class Organization extends JetstreamTeam
{
use HasFactory;
use HasUuids;

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Laravel\Jetstream\Jetstream;
use Laravel\Jetstream\TeamInvitation as JetstreamTeamInvitation;
/**
* @property string $id
* @property string $email
*/
class OrganizationInvitation extends JetstreamTeamInvitation
{
use HasUuids;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'organization_invitations';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'email',
'role',
];
/**
* Get the organization that the invitation belongs to.
*/
public function organization(): BelongsTo
{
return $this->belongsTo(Jetstream::teamModel(), 'organization_id');
}
/**
* Get the organization that the invitation belongs to.
*/
public function team(): BelongsTo
{
return $this->belongsTo(Jetstream::teamModel(), 'organization_id');
}
}

View File

@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @property string $name
* @property string $organization_id
* @property string $client_id
* @property-read Team $organization
* @property-read Organization $organization
* @property-read Client|null $client
* @property-read Collection<Task> $tasks
*
@@ -38,11 +38,11 @@ class Project extends Model
];
/**
* @return BelongsTo<Team, Project>
* @return BelongsTo<Organization, Project>
*/
public function organization(): BelongsTo
{
return $this->belongsTo(Team::class, 'organization_id');
return $this->belongsTo(Organization::class, 'organization_id');
}
/**

View File

@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property string $id
* @property string $name
* @property string $organization_id
* @property-read Team $organization
* @property-read Organization $organization
*
* @method static TagFactory factory()
*/
@@ -33,10 +33,10 @@ class Tag extends Model
];
/**
* @return BelongsTo<Team, Tag>
* @return BelongsTo<Organization, Tag>
*/
public function organization(): BelongsTo
{
return $this->belongsTo(Team::class, 'organization_id');
return $this->belongsTo(Organization::class, 'organization_id');
}
}

View File

@@ -16,7 +16,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property string $project_id
* @property string $organization_id
* @property-read Project $project
* @property-read Team $organization
* @property-read Organization $organization
*
* @method static TaskFactory factory()
*/
@@ -43,10 +43,10 @@ class Task extends Model
}
/**
* @return BelongsTo<Team, Task>
* @return BelongsTo<Organization, Task>
*/
public function organization(): BelongsTo
{
return $this->belongsTo(Team::class, 'organization_id');
return $this->belongsTo(Organization::class, 'organization_id');
}
}

View File

@@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Laravel\Jetstream\Jetstream;
use Laravel\Jetstream\TeamInvitation as JetstreamTeamInvitation;
class TeamInvitation extends JetstreamTeamInvitation
{
use HasUuids;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'email',
'role',
];
/**
* Get the team that the invitation belongs to.
*/
public function team(): BelongsTo
{
return $this->belongsTo(Jetstream::teamModel());
}
}

View File

@@ -19,7 +19,7 @@ use Illuminate\Support\Carbon;
* @property bool $billable
* @property array $tags
* @property-read User $user
* @property-read Team $organization
* @property-read Organization $organization
* @property-read Project|null $project
* @property-read Task|null $task
*
@@ -52,11 +52,11 @@ class TimeEntry extends Model
}
/**
* @return BelongsTo<Team, TimeEntry>
* @return BelongsTo<Organization, TimeEntry>
*/
public function organization(): BelongsTo
{
return $this->belongsTo(Team::class, 'organization_id');
return $this->belongsTo(Organization::class, 'organization_id');
}
/**

View File

@@ -8,6 +8,7 @@ use Database\Factories\UserFactory;
use Filament\Panel;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -20,7 +21,7 @@ use Laravel\Passport\HasApiTokens;
* @property string $id
* @property string $name
*
* @method HasMany<Team> ownedTeams()
* @method HasMany<Organization> ownedTeams()
* @method static UserFactory factory()
*/
class User extends Authenticatable
@@ -79,4 +80,17 @@ class User extends Authenticatable
// TODO: Implement canAccessPanel() method.
return false;
}
/**
* @return BelongsToMany<Organization>
*/
public function organizations(): BelongsToMany
{
return $this->belongsToMany(Organization::class, Membership::class)
->withPivot([
'role',
])
->withTimestamps()
->as('membership');
}
}