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