mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 15:34:37 -04:00
Fixes for tests
This commit is contained in:
parent
e21e70bdcd
commit
d11cc1784d
@ -495,8 +495,79 @@ class CompanyController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ob_flush();
|
|
||||||
|
|
||||||
return response()->json(['message' => 'success'], 200);
|
return response()->json(['message' => 'success'], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Purge Company
|
||||||
|
*
|
||||||
|
* @OA\Post(
|
||||||
|
* path="/api/v1/companies/purge/{company}",
|
||||||
|
* operationId="postCompanyPurge",
|
||||||
|
* tags={"companies"},
|
||||||
|
* summary="Attempts to purge a company record and all its child records",
|
||||||
|
* description="Attempts to purge a company record and all its child records",
|
||||||
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
|
||||||
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
||||||
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||||
|
* @OA\Parameter(
|
||||||
|
* name="company",
|
||||||
|
* in="path",
|
||||||
|
* description="The Company Hashed ID",
|
||||||
|
* example="D2J234DFA",
|
||||||
|
* required=true,
|
||||||
|
* @OA\Schema(
|
||||||
|
* type="string",
|
||||||
|
* format="string",
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Returns a refresh object",
|
||||||
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||||
|
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||||
|
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||||
|
* @OA\JsonContent(ref="#/components/schemas/CompanyUser"),
|
||||||
|
* ),
|
||||||
|
* @OA\Response(
|
||||||
|
* response=422,
|
||||||
|
* description="Validation error",
|
||||||
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||||
|
* ),
|
||||||
|
* @OA\Response(
|
||||||
|
* response="default",
|
||||||
|
* description="Unexpected Error",
|
||||||
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||||
|
* ),
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function purgeCompany(Company $company)
|
||||||
|
{
|
||||||
|
$account = $company->account;
|
||||||
|
$company_id = $company->id;
|
||||||
|
|
||||||
|
$company->delete();
|
||||||
|
|
||||||
|
if($account->companies->count() >= 1)
|
||||||
|
auth()->user()->setCompany($account->companies->first());
|
||||||
|
|
||||||
|
if($company_id == $account->default_company_id){
|
||||||
|
|
||||||
|
$new_default_company = $account->companies->first();
|
||||||
|
|
||||||
|
if($new_default_company){
|
||||||
|
$account->default_company_id = $new_default_company->id;
|
||||||
|
$account->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entity_type = CompanyUser::class;
|
||||||
|
$this->entity_transformer = CompanyUserTransformer::class;
|
||||||
|
|
||||||
|
$company_user = $account->company_users->where('user_id', auth()->user()->id);
|
||||||
|
|
||||||
|
return $this->refreshResponse($company_user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,18 +77,7 @@ class MigrationController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function purgeCompany(Company $company)
|
public function purgeCompany(Company $company)
|
||||||
{
|
{
|
||||||
// $account = $company->account;
|
|
||||||
|
|
||||||
// if($account->default_company_id == $company->id)
|
|
||||||
// {
|
|
||||||
// $companies = $account->companies;
|
|
||||||
|
|
||||||
// if($companies->count() > 1)
|
|
||||||
// {
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
$company->delete();
|
$company->delete();
|
||||||
|
|
||||||
return response()->json(['message' => 'Company purged'], 200);
|
return response()->json(['message' => 'Company purged'], 200);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user