Yes, you're correct. When you use $user->my_price(), Laravel will treat it as a relationship query. If you want to use a method to format your price, you should use $user->myPrice(). However, in your case, I would suggest using an accessor instead.
An accessor in Laravel allows you to format Eloquent attribute values when you access them on your models. Here's how you can define an accessor for your my_price attribute:
public function getMyPriceAttribute($value)
{
return '$' . $value / 100;
}
Now, you can access the formatted price like this:
echo $user->my_price;
This will automatically call the getMyPriceAttribute method and return the formatted price.
Remember, when defining an accessor, the get prefix is followed by the StudlyCase version of the column name. Also, Laravel will automatically call the accessor, so there's no need to add parentheses () when accessing it.
This way, you can keep your view clean and all the formatting logic in your model.