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

@@ -37,12 +37,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* FireflyIII\Models\Preference
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property null|Carbon $created_at
* @property null|Carbon $updated_at
* @property int $user_id
* @property string $name
* @property int|string|array|null $data
* @property-read User $user
* @property null|array|int|string $data
* @property User $user
*
* @method static Builder|Preference newModelQuery()
* @method static Builder|Preference newQuery()
* @method static Builder|Preference query()
@@ -52,6 +53,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Preference whereName($value)
* @method static Builder|Preference whereUpdatedAt($value)
* @method static Builder|Preference whereUserId($value)
*
* @mixin Eloquent
*/
class Preference extends Model
@@ -66,15 +68,11 @@ class Preference extends Model
'data' => 'array',
];
protected $fillable = ['user_id', 'data', 'name'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Preference
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): self
@@ -82,7 +80,8 @@ class Preference extends Model
if (auth()->check()) {
/** @var User $user */
$user = auth()->user();
/** @var Preference|null $preference */
/** @var null|Preference $preference */
$preference = $user->preferences()->where('name', $value)->first();
if (null === $preference) {
$preference = $user->preferences()->where('id', (int)$value)->first();
@@ -101,12 +100,10 @@ class Preference extends Model
return $preference;
}
}
throw new NotFoundHttpException();
}
/**
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);