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