This is my query:
$data = Collections::select(DB:raw("REGEXP_REPLACE(tour_id,'(,2|2,|2)','') as `new_tour_id"))->get();
I want to convert this query to update all my records in the database.
This is my database table shows:
I want this result:
2
Answers
Since Laravel 5.x allows attribute casting so it’s possible to cast attributes to another data type for converting on runtime.
In this case, just declare a protected $casts property for example:
then store your ids like this
and finally search like this :
read more :
JSON Where Clauses
Assuming that you have a model for this table as
Tour
what you have to do is this: