I have a table with 10 fields with these names: field1, field2, and so on... I want to retrieve a single registrer (wtih eloquent and ->first() ). And when i have the object (lets say $user), can I do something like this in the controller?
for ($i=1; $i<=10; $i++) {
$field_name = 'field'.$i;
if ($user->$field_name == 1) {
// do something
}
}
Or i have to call them manually?
if ($user->field1 == 1) {
// do something
}
if ($user->field2 == 1) {
// do something
}
....