Merge pull request #3783 from turbo124/v2

Test data set
This commit is contained in:
David Bomba 2020-06-04 21:35:51 +10:00 committed by GitHub
commit cc7bcdeb0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 3 deletions

View File

@ -315,7 +315,7 @@ class CreateTestData extends Command
]);
factory(\App\Models\Product::class, 50)->create([
factory(\App\Models\Product::class, 15000)->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);

View File

@ -424,4 +424,73 @@ class CompanyGatewayController extends BaseController
return response()->json([], 200);
}
/**
* Perform bulk actions on the list view
*
* @param BulkCompanyGatewayRequest $request
* @return \Illuminate\Http\Response
*
*
* @OA\Post(
* path="/api/v1/company_gateways/bulk",
* operationId="bulkCompanyGateways",
* tags={"company_gateways"},
* summary="Performs bulk actions on an array of company_gateways",
* description="",
* @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(ref="#/components/parameters/index"),
* @OA\RequestBody(
* description="Array of company gateway IDs",
* required=true,
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* type="array",
* @OA\Items(
* type="integer",
* description="Array of hashed IDs to be bulk 'actioned",
* example="[0,1,2,3]",
* ),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="The Company Gateways response",
* @OA\Header(header="X-API-Version", ref="#/components/headers/X-API-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/CompanyGateway"),
* ),
* @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 bulk()
{
$action = request()->input('action');
$ids = request()->input('ids');
$company_gateways = CompanyGateway::withTrashed()->find($this->transformKeys($ids));
$company_gateways->each(function ($company_gateway, $key) use ($action) {
if (auth()->user()->can('edit', $company_gateway)) {
$this->company_repo->{$action}($client);
}
});
return $this->listResponse(CompanyGateway::withTrashed()->whereIn('id', $this->transformKeys($ids)));
}
}

View File

@ -12,7 +12,6 @@
namespace App\Http\Controllers;
use App\Utils\Ninja;
use Codedge\Updater\UpdaterManager;
use Composer\Factory;
use Composer\IO\NullIO;
use Composer\Installer;

View File

@ -228,7 +228,6 @@ return [
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Updater' => Codedge\Updater\UpdaterFacade::class,
/*
* Dependency Facades
*/

View File

@ -189,5 +189,10 @@ class CountriesSeeder extends Seeder
}
$country->save();
}
$p = Country::where('country_code', 275)->first();
$p->name = 'Palestine';
$p->save();
}
}

View File

@ -102,6 +102,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::resource('company_gateways', 'CompanyGatewayController');
Route::post('company_gateways/bulk', 'CompanyGatewayController@bulk')->name('company_gateways.bulk');
Route::put('company_users/{user}', 'CompanyUserController@update');
Route::resource('group_settings', 'GroupSettingController');