action = $action; $this->request = $request; $this->model = $drcrnote_detail; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(DrcrnoteDetail $drcrnote_detail, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $drcrnote_detail = $drcrnote_detail->create($attributes); return $drcrnote_detail; } public function update(DrcrnoteDetail $drcrnote_detail, array $request) { $attributes = $request; $drcrnote_detail->update($attributes); return $drcrnote_detail; } public function destroy(DrcrnoteDetail $drcrnote_detail, array $request) { $drcrnote_detail->delete(); return $drcrnote_detail; } public function copy(DrcrnoteDetail $drcrnote_detail, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $drcrnote_detail = $drcrnote_detail->replicate(); $drcrnote_detail->created_at = Carbon::now(); $drcrnote_detail->save(); return $drcrnote_detail; } for ($i = 1; $i <= $count; $i++) { $new = $drcrnote_detail->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $drcrnote_detail; } }