übergang auf pakete, integration von stripe und paypal, blog hinzugefügt.
This commit is contained in:
@@ -18,6 +18,8 @@ class Event extends Model
|
||||
'date' => 'datetime',
|
||||
'settings' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'name' => 'array',
|
||||
'description' => 'array',
|
||||
];
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
|
||||
@@ -40,13 +40,7 @@ class Package extends Model
|
||||
'features' => 'array',
|
||||
];
|
||||
|
||||
protected function features(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn (mixed $value) => $value ? json_decode($value, true) : [],
|
||||
set: fn (array $value) => json_encode($value),
|
||||
);
|
||||
}
|
||||
// features handled by $casts = ['features' => 'array']
|
||||
|
||||
public function eventPackages(): HasMany
|
||||
{
|
||||
|
||||
@@ -78,6 +78,10 @@ class PackagePurchase extends Model
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($purchase) {
|
||||
if (!$purchase->tenant_id) {
|
||||
throw new \Exception('Tenant ID is required for package purchases.');
|
||||
}
|
||||
|
||||
if (!$purchase->purchased_at) {
|
||||
$purchase->purchased_at = now();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ class Task extends Model
|
||||
protected $casts = [
|
||||
'due_date' => 'datetime',
|
||||
'is_completed' => 'bool',
|
||||
'title' => 'array',
|
||||
'description' => 'array',
|
||||
'example_text' => 'array',
|
||||
];
|
||||
|
||||
public function emotion(): BelongsTo
|
||||
|
||||
@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Tenant extends Model
|
||||
@@ -51,9 +53,9 @@ class Tenant extends Model
|
||||
return $this->hasMany(TenantPackage::class);
|
||||
}
|
||||
|
||||
public function activeResellerPackage()
|
||||
public function activeResellerPackage(): HasOne
|
||||
{
|
||||
return $this->tenantPackages()->where('active', true)->first();
|
||||
return $this->hasOne(TenantPackage::class)->where('active', true);
|
||||
}
|
||||
|
||||
public function canCreateEvent(): bool
|
||||
@@ -93,4 +95,9 @@ class Tenant extends Model
|
||||
get: fn () => $this->activeResellerPackage() !== null,
|
||||
);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
@@ -25,6 +27,10 @@ class User extends Authenticatable
|
||||
'password',
|
||||
'username',
|
||||
'preferred_locale',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'address',
|
||||
'phone',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -50,8 +56,15 @@ class User extends Authenticatable
|
||||
];
|
||||
}
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
protected function fullName(): Attribute
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
return Attribute::make(
|
||||
get: fn () => $this->first_name . ' ' . $this->last_name,
|
||||
);
|
||||
}
|
||||
|
||||
public function tenant(): HasOne
|
||||
{
|
||||
return $this->hasOne(Tenant::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user