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