109 lines
3.5 KiB
PHP
109 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\API\AccountRequest;
|
|
use App\Http\Resources\AccountResource;
|
|
|
|
class AccountController extends Controller
|
|
{
|
|
/**
|
|
* @OA\GET(
|
|
* path="/api/account",
|
|
* summary=" - Get client account",
|
|
* tags = {"Account"},
|
|
* security={
|
|
* {"bearerAuth": {}}
|
|
* },
|
|
* @OA\Response(
|
|
* response="200",
|
|
* description="OK"
|
|
* ),
|
|
* @OA\Response(
|
|
* response="401",
|
|
* description="Unauthorized"
|
|
* )
|
|
* )
|
|
*/
|
|
public function get(){
|
|
$client = request()->user();
|
|
|
|
if($account = $client->account){
|
|
return AccountResource::make($account);
|
|
}
|
|
|
|
return response()->json(['message'=> trans('app.account.not_found')],404 );
|
|
}
|
|
|
|
/**
|
|
* @OA\POST(
|
|
* path="/api/update-account",
|
|
* summary=" - Update account",
|
|
* tags = {"Account"},
|
|
* security={
|
|
* {"bearerAuth": {}}
|
|
* },
|
|
* @OA\RequestBody(
|
|
* @OA\MediaType(
|
|
* mediaType="application/json",
|
|
* @OA\Schema(
|
|
* @OA\Property(
|
|
* property="contacts",
|
|
* type="string",
|
|
* ),
|
|
* @OA\Property(
|
|
* property="bank",
|
|
* type="string",
|
|
* ),
|
|
* @OA\Property(
|
|
* property="vat",
|
|
* type="string",
|
|
* ),
|
|
* @OA\Property(
|
|
* property="country_id",
|
|
* type="integer",
|
|
* ),
|
|
* @OA\Property(
|
|
* property="legalization_number",
|
|
* type="string",
|
|
* ),
|
|
* @OA\Property(
|
|
* property="type",
|
|
* type="string",
|
|
* ),
|
|
* example={"contacts":"{'address':'Ashgabat', 'phone': '+99362553499', 'email': 'ilmedovamahri@gmail.com', 'fax': '414141'}", "bank":"{'account_number':'12345','account_date':'02.02.2022','currency':'USD', 'iban':'747474', 'bank_name':'Vnezhekonom', 'country':'France'}" ,"vat": "123123", "country_id": 1, "legalization_number": "123456","type":"business"}
|
|
* )
|
|
* )
|
|
* ),
|
|
* @OA\Parameter(
|
|
* description="Localization",
|
|
* in="header",
|
|
* name="X-Localization",
|
|
* required=false,
|
|
* @OA\Schema(type="string"),
|
|
* @OA\Examples(example="ru", value="ru", summary="Russian localization"),
|
|
* @OA\Examples(example="en", value="en", summary="English localization"),
|
|
* @OA\Examples(example="tm", value="tm", summary="Turkmen localization"),
|
|
* ),
|
|
* @OA\Response(
|
|
* response="200",
|
|
* description="OK"
|
|
* ),
|
|
* @OA\Response(
|
|
* response="401",
|
|
* description="Unauthorized"
|
|
* )
|
|
* )
|
|
*/
|
|
public function update(AccountRequest $request){
|
|
|
|
$client = $request->user();
|
|
|
|
$account = $client->account;
|
|
|
|
$account->fill($request->all())->save();
|
|
|
|
return AccountResource::make($account);
|
|
}
|
|
}
|