where('user_id',$actor->id)->where('tenant_id',$data['tenant_id'])->where('company_id',$data['company_id'])->exists() && app(\App\Modules\Identity\Services\Permissions::class)->has($actor->id,(int)$data['tenant_id'],(int)$data['company_id'],'company.view'); if($permitted) { $module=$this->moduleFixture(); $profile=$actor->id.':'.$data['tenant_id'].':'.$data['company_id']; config(['modules.development_profiles'=>array_values(array_unique([...config('modules.development_profiles',[]),$profile]))]); // The suite's freshly created fixture has this explicitly declared purpose. // This does not run on existing/demo data, or in application middleware. foreach(ModuleRecords::AREAS as $area) { $scope=['tenant_id'=>$data['tenant_id'],'company_id'=>$data['company_id'],'unit_id'=>str_ends_with($area,'_drafts')?($data['unit_id']??null):null]; foreach(DB::table('a_'.$area)->where($scope)->get(['id','version']) as $row) { $exists=DB::table('identity_audit')->where('action','module.record.associated')->where('tenant_id',$scope['tenant_id'])->where('company_id',$scope['company_id']) ->whereRaw("details::jsonb->>'area' = ?",[$area])->whereRaw("details::jsonb->>'record_id' = ?",[(string)$row->id])->whereRaw("details::jsonb->>'module_id' = ?",[$module])->exists(); if(!$exists)ModuleRecords::associate($area,$row->id,$actor->id,$scope,$module,'Explicit newly-created regression fixture: '.static::class,false,(int)$row->version); } } $data['module_id']=$module; } } return parent::postJson($uri,$data,$headers,$options); } public function getJson($uri, array $headers = [], $options = 0) { // Historical read assertions previously had no generation header. Writes // retain their explicitly supplied tokens, including intentional stale ones. $token=app('session.store')->get('company_context.token'); if($token && !array_key_exists('X-SGF-Context',$headers))$headers['X-SGF-Context']=$token; return parent::getJson($uri,$headers,$options); } }