I have a (string) column which holds array data which the model casts. The array holds integers. I'm trying to get eloquent to see if the submitted value is in the stored array. I can get it to work using:
For a bit more information this is part of a scheduling application. There are two tables; 'job_plans' and 'job_plan_sessions'.
The job plan hold a integer which is the job plan cycle length (e.g. 4 means it runs week 1,2,3,4 then back to week 1). This value is definable by the user. The sessions table holds the array of weeks worked, again definable by the user.
My only other thought is having a table of job_plan_session_weeks and in that table have job plan ID, and weeks. Then pull all weeks with that job plan ID, handling it that way.
Only because there's a variety of other information which goes with it. I'm on my mobile at the minute but can provide a full schema later if you wish.
I've never used the JSON column type but it might be your friend here. From my limited understanding it's possible to carry out queries on the data in a JSON column.
So I've managed to get it working without using an extra table. I've converted the column to json in the migration, it still casts as an array field. To query I have the following (as part of a larger query):