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