Can I get a dump of the $processes and $maintenance?
I did a quick script of what I believe you're trying to achieve and it works for me. I get an output of 55155 which shows that the 3 is missing from the $processes array.
$processes = [1, 2, 4, 5];
$maintenance = [1, 2, 3, 4, 5];
$array_value = function ($value, $array) {
$str = "$value";
if (in_array($str, $array)) {
echo 5;
} else {
echo 1;
}
};
foreach ($maintenance as $m) {
$array_value ($m, $processes);
}
Does this work : ####Logic
$processes = DB::table('services')->get();
$process_id_all = array_pluck($processes, 'id');
$maintenances = DB::table('maintenances')
->select('id')
->whereCarId($id)
->groupBy('category_id')->get();
$process_id_maintainance = array_pluck($maintenance, 'process_id');
####View
@foreach ($maintenances as $maintenance)
Id : {{ $maintenance->id }}
Process :
@if (in_array($process_id_maintainance, $process_id_all))
{{ $maintenance->process }}
@else
Record missing;
@endif
@endforeach
could you use the array_diff or array_intersect methods?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community