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