Support the ongoing development of Laravel.io →
Database Eloquent Views
Last updated 1 year ago.
0

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);
}
Last updated 1 year ago.
0

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
Last updated 1 year ago.
0

could you use the array_diff or array_intersect methods?

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

laureta laureta Joined 17 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.