formatting, juiste use voor UpdateDynamicRequest
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Dynamic extends Model
|
||||
{
|
||||
@@ -47,7 +48,7 @@ class Dynamic extends Model
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = (string) \Illuminate\Support\Str::uuid();
|
||||
$model->uuid = (string) Str::uuid();
|
||||
});
|
||||
|
||||
static::created(function (Dynamic $dynamic) {
|
||||
|
||||
@@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class DynamicInvitation extends Model {
|
||||
class DynamicInvitation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -21,11 +22,13 @@ class DynamicInvitation extends Model {
|
||||
'expires_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function dynamic(): BelongsTo {
|
||||
public function dynamic(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Dynamic::class);
|
||||
}
|
||||
|
||||
public function isExpired(): bool {
|
||||
public function isExpired(): bool
|
||||
{
|
||||
return $this->expires_at->isPast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Ledger extends Model
|
||||
{
|
||||
@@ -37,7 +39,7 @@ class Ledger extends Model
|
||||
return $this->hasMany(PredefinedMutation::class);
|
||||
}
|
||||
|
||||
public function media(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
public function media(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
@@ -45,7 +47,7 @@ class Ledger extends Model
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = (string) \Illuminate\Support\Str::uuid();
|
||||
$model->uuid = (string) Str::uuid();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Media extends Model {
|
||||
class Media extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -17,11 +18,13 @@ class Media extends Model {
|
||||
|
||||
protected $appends = ['url'];
|
||||
|
||||
public function mediable(): MorphTo {
|
||||
public function mediable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function getUrlAttribute(): string {
|
||||
return asset('storage/' . $this->file_path);
|
||||
public function getUrlAttribute(): string
|
||||
{
|
||||
return asset('storage/'.$this->file_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Database\Factories\MessageFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Message extends Model
|
||||
@@ -37,7 +37,7 @@ class Message extends Model
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function media(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
public function media(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\MessageSent;
|
||||
use Database\Factories\MutationFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Mutation extends Model
|
||||
{
|
||||
@@ -43,7 +46,7 @@ class Mutation extends Model
|
||||
return $this->morphOne(Chat::class, 'chatable');
|
||||
}
|
||||
|
||||
public function media(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
public function media(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
@@ -51,7 +54,7 @@ class Mutation extends Model
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = (string) \Illuminate\Support\Str::uuid();
|
||||
$model->uuid = (string) Str::uuid();
|
||||
});
|
||||
|
||||
static::created(function (Mutation $mutation) {
|
||||
@@ -71,24 +74,24 @@ class Mutation extends Model
|
||||
'subject_id' => $mutation->id,
|
||||
'subject_type' => Mutation::class,
|
||||
]);
|
||||
broadcast(new \App\Events\MessageSent($mutationMsg));
|
||||
broadcast(new MessageSent($mutationMsg));
|
||||
|
||||
if ($status === 'approved') {
|
||||
$dynamicMsg = $dynamic->chat->messages()->create([
|
||||
'user_id' => null,
|
||||
'content' => "<user:{$user->id}> added entry \"{$mutation->description}\" for " . ($mutation->amount >= 0 ? '+' : '') . "{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
'content' => "<user:{$user->id}> added entry \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
'subject_id' => $mutation->id,
|
||||
'subject_type' => Mutation::class,
|
||||
]);
|
||||
} else {
|
||||
$dynamicMsg = $dynamic->chat->messages()->create([
|
||||
'user_id' => null,
|
||||
'content' => "<user:{$user->id}> suggested \"{$mutation->description}\" for " . ($mutation->amount >= 0 ? '+' : '') . "{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
'content' => "<user:{$user->id}> suggested \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
'subject_id' => $mutation->id,
|
||||
'subject_type' => Mutation::class,
|
||||
]);
|
||||
}
|
||||
broadcast(new \App\Events\MessageSent($dynamicMsg));
|
||||
broadcast(new MessageSent($dynamicMsg));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PredefinedMutation extends Model
|
||||
{
|
||||
@@ -26,7 +27,7 @@ class PredefinedMutation extends Model
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = (string) \Illuminate\Support\Str::uuid();
|
||||
$model->uuid = (string) Str::uuid();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\Contracts\PasskeyUser;
|
||||
use Laravel\Fortify\PasskeyAuthenticatable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
@@ -33,7 +34,7 @@ use NotificationChannels\WebPush\HasPushSubscriptions;
|
||||
class User extends Authenticatable implements PasskeyUser
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable, HasPushSubscriptions;
|
||||
use HasFactory, HasPushSubscriptions, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
|
||||
|
||||
public function dynamics()
|
||||
{
|
||||
@@ -74,7 +75,7 @@ class User extends Authenticatable implements PasskeyUser
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = (string) \Illuminate\Support\Str::uuid();
|
||||
$model->uuid = (string) Str::uuid();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user