mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 06:01:21 +00:00
Replace Laravel binder with own binder. This will save in queries and increase security.
This commit is contained in:
@@ -52,21 +52,24 @@ class RuleGroup extends Model
|
||||
protected $fillable = ['user_id', 'order', 'title', 'description', 'active'];
|
||||
|
||||
/**
|
||||
* @param RuleGroup $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return RuleGroup
|
||||
*/
|
||||
public static function routeBinder(RuleGroup $value)
|
||||
public static function routeBinder(string $value): RuleGroup
|
||||
{
|
||||
if (auth()->check()) {
|
||||
if (intval($value->user_id) === auth()->user()->id) {
|
||||
return $value;
|
||||
$ruleGroupId = intval($value);
|
||||
$ruleGroup = auth()->user()->ruleGroups()->find($ruleGroupId);
|
||||
if (!is_null($ruleGroup)) {
|
||||
return $ruleGroup;
|
||||
}
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function rules()
|
||||
@@ -75,6 +78,7 @@ class RuleGroup extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
|
||||
Reference in New Issue
Block a user