Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -41,21 +41,22 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* FireflyIII\Models\RuleGroup
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property null|Carbon $created_at
* @property null|Carbon $updated_at
* @property null|Carbon $deleted_at
* @property int $user_id
* @property string|null $title
* @property string|null $description
* @property null|string $title
* @property null|string $description
* @property int $order
* @property bool $active
* @property bool $stop_processing
* @property Collection|Rule[] $rules
* @property-read int|null $rules_count
* @property-read User $user
* @property null|int $rules_count
* @property User $user
*
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newQuery()
* @method static Builder|RuleGroup onlyTrashed()
* @method static Builder|RuleGroup onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup query()
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereCreatedAt($value)
@@ -67,10 +68,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserId($value)
* @method static Builder|RuleGroup withTrashed()
* @method static Builder|RuleGroup withoutTrashed()
* @property int $user_group_id
* @method static Builder|RuleGroup withTrashed()
* @method static Builder|RuleGroup withoutTrashed()
*
* @property int $user_group_id
*
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)
*
* @mixin Eloquent
*/
class RuleGroup extends Model
@@ -79,7 +83,6 @@ class RuleGroup extends Model
use ReturnsIntegerUserIdTrait;
use SoftDeletes;
protected $casts
= [
'created_at' => 'datetime',
@@ -90,55 +93,45 @@ class RuleGroup extends Model
'order' => 'int',
];
protected $fillable = ['user_id', 'user_group_id', 'stop_processing', 'order', 'title', 'description', 'active'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return RuleGroup
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$ruleGroupId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var RuleGroup|null $ruleGroup */
/** @var null|RuleGroup $ruleGroup */
$ruleGroup = $user->ruleGroups()->find($ruleGroupId);
if (null !== $ruleGroup) {
return $ruleGroup;
}
}
throw new NotFoundHttpException();
}
/**
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return HasMany
*/
public function rules(): HasMany
{
return $this->hasMany(Rule::class);
}
/**
* @return Attribute
*/
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}