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