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