mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 14:34:34 -04:00
Add subscription delete routes
This commit is contained in:
parent
f5092e8cf4
commit
4ede6bd41e
@ -24,9 +24,12 @@ use App\Models\Subscription;
|
|||||||
use App\Repositories\SubscriptionRepository;
|
use App\Repositories\SubscriptionRepository;
|
||||||
use App\Transformers\SubscriptionTransformer;
|
use App\Transformers\SubscriptionTransformer;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class SubscriptionController extends BaseController
|
class SubscriptionController extends BaseController
|
||||||
{
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
protected $entity_type = Subscription::class;
|
protected $entity_type = Subscription::class;
|
||||||
|
|
||||||
protected $entity_transformer = SubscriptionTransformer::class;
|
protected $entity_transformer = SubscriptionTransformer::class;
|
||||||
@ -407,4 +410,72 @@ class SubscriptionController extends BaseController
|
|||||||
|
|
||||||
return $this->itemResponse($subscription->fresh());
|
return $this->itemResponse($subscription->fresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform bulk actions on the list view.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @OA\Post(
|
||||||
|
* path="/api/v1/subscriptions/bulk",
|
||||||
|
* operationId="bulkSubscriptions",
|
||||||
|
* tags={"subscriptions"},
|
||||||
|
* summary="Performs bulk actions on an array of subscriptions",
|
||||||
|
* 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="User credentials",
|
||||||
|
* 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 Subscription response",
|
||||||
|
* @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/Subscription"),
|
||||||
|
* ),
|
||||||
|
* @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');
|
||||||
|
$subscriptions = Subscription::withTrashed()->find($this->transformKeys($ids));
|
||||||
|
|
||||||
|
$subscriptions->each(function ($subscription, $key) use ($action) {
|
||||||
|
if (auth()->user()->can('edit', $subscription)) {
|
||||||
|
$this->subscription_repo->{$action}($subscription);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->listResponse(Subscription::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
|||||||
// Route::delete('hooks/{subscription_id}', 'SubscriptionController@unsubscribe')->name('hooks.unsubscribe');
|
// Route::delete('hooks/{subscription_id}', 'SubscriptionController@unsubscribe')->name('hooks.unsubscribe');
|
||||||
|
|
||||||
Route::resource('subscriptions', 'SubscriptionController');
|
Route::resource('subscriptions', 'SubscriptionController');
|
||||||
|
Route::post('subscriptions/bulk', 'SubscriptionController@bulk')->name('subscriptions.bulk');
|
||||||
|
|
||||||
Route::resource('cliente_subscriptions', 'ClientSubscriptionController');
|
Route::resource('cliente_subscriptions', 'ClientSubscriptionController');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user