authorizeIe('ie.research.view'); $businessId = $this->businessId(); if ($request->ajax()) { return DataTables::of(ResearchProject::forBusiness($businessId)) ->addColumn('action', fn ($row) => '') ->rawColumns(['action']) ->make(true); } return view('industrialengineering::research.index'); } public function create() { $this->authorizeIe('ie.research.create'); return view('industrialengineering::research.create'); } public function store(Request $request) { $this->authorizeIe('ie.research.create'); $data = $request->validate([ 'project_code' => 'required|string|max:100', 'name' => 'required|string|max:255', 'research_type' => 'required|string', 'objective' => 'nullable|string', ]); $data['business_id'] = $this->businessId(); $data['lead_researcher_id'] = auth()->id(); $project = ResearchProject::create($data); return redirect()->action([self::class, 'show'], $project->id) ->with('status', ['success' => true, 'msg' => __('industrialengineering::lang.saved')]); } public function show($id) { $this->authorizeIe('ie.research.view'); $project = ResearchProject::forBusiness($this->businessId()) ->with(['competitiveProducts.structures', 'benchmarks', 'findings']) ->findOrFail($id); return view('industrialengineering::research.show', compact('project')); } public function addCompetitor(Request $request, $id) { $this->authorizeIe('ie.research.create'); $project = ResearchProject::forBusiness($this->businessId())->findOrFail($id); $data = $request->validate([ 'competitor_name' => 'required|string|max:255', 'product_name' => 'required|string|max:255', 'estimated_price' => 'nullable|numeric|min:0', 'notes' => 'nullable|string', ]); $data['business_id'] = $this->businessId(); $data['research_project_id'] = $project->id; CompetitiveProduct::create($data); return back()->with('status', ['success' => true, 'msg' => __('industrialengineering::lang.competitor_added')]); } }