Here is a raw SQL query:
SELECT name, area, point(area) AS center FROM places;
I want to get an Eloquent model based on this query. Here is the Model:
class Place extends Model
{
protected $visible = ['name', 'area'];
}
So, I want to get the center property if I run this code:
return response()->json( Place::all() );
center is missing. I don't know how to add the center property in my Place object. I don't want to build a raw query in my controller, is there any solution with mutator or something like this? (The only thing I want to call is Place::all(), I really want to use Eloquent Model in controllers, not an SQL query).