Choose select method to display the result well

Viewed 32

Here you see that it shows me 2 times extruder, it only has to appear once since line 1 has an extruder, but line 2 also has an extruder, I only want it to appear when I choose the respective line

This is my model, it is my method that I use to bring the data, but I want it to only show me the equipment registered with the machinery.

public function scopeAllEquipmentChild($query)
{
    return EquipmentChild::with('machinery', 'equipment')->
        leftjoin('equipment','equipment_children.equipment_id','=','equipment.id')
            ->join('machineries','equipment.machinery_id','=','machineries.id')
                ->select('equipment_children.*','equipment_children.name','equipment.machinery_id','machineries.area_id')
                    ->get();
}

this is my controller

public function create(Request $request)
{
    $machineries=machinery::pluck('name','id')->all();
    $areas=area::pluck('name','id')->all();
    return view('admin.equipment.create',compact('areas','machineries'));
}

/**
 * @param \App\Http\Requests\EquipmentStoreRequest $request
 * @return \Illuminate\Http\Response
 */
public function store(EquipmentStoreRequest $request)
{
    $equipment = Equipment::create($request->validated());

    $request->session()->flash('equipment.id', $equipment->id);

    return redirect()->route('admin.equipment.index');
}
0 Answers
Related