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