Skip to content
Discussion options

You must be logged in to vote

Okay, I know the problem. This was my code I hoped would work:

protected function nameFinal(): Attribute{
	return Attribute::make(static function(mixed $value,array $attributes){
		dump(get_defined_vars(),$this);
	})->shouldCache();
}

But this didn't work, so I made it like this:

protected function nameFinal(): Attribute{
	$record = $this;
	return Attribute::make(static function(mixed $value,array $attributes) use($record){
		dump(get_defined_vars(),$record);
	})->shouldCache();
}

However, it can be much simpler. First of all, get_defined_vars() will not list $this, so only $value and $attributes are visible. It isn't a good function to see if you have access to $this. The real problem wa…

Replies: 4 comments 11 replies

Comment options

You must be logged in to vote
7 replies
@ghost
Comment options

@ben221199
Comment options

@ben221199
Comment options

@ben221199
Comment options

@ghost
Comment options

Comment options

You must be logged in to vote
2 replies
@ben221199
Comment options

@ben221199
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ben221199
Comment options

You must be logged in to vote
2 replies
@ben221199
Comment options

@ghost
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants