|
|
|
@ -2,11 +2,11 @@ |
|
|
|
|
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
use App\Entities\Subscriptions\Type; |
|
|
|
use App\Entities\Subscriptions\Subscription; |
|
|
|
use App\Entities\Subscriptions\SubscriptionsRepository; |
|
|
|
use App\Entities\Subscriptions\Type; |
|
|
|
use App\Http\Requests\SubscriptionRequest as FormRequest; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
|
/** |
|
|
|
* Subscriptions Controller. |
|
|
|
@ -15,13 +15,27 @@ use Illuminate\Http\Request; |
|
|
|
*/ |
|
|
|
class SubscriptionsController extends Controller |
|
|
|
{ |
|
|
|
/** |
|
|
|
* @var \App\Entities\Subscriptions\SubscriptionsRepository |
|
|
|
*/ |
|
|
|
private $repo; |
|
|
|
|
|
|
|
/** |
|
|
|
* Create new Subscription Controller. |
|
|
|
* |
|
|
|
* @param \App\Entities\Subscriptions\SubscriptionsRepository $repo |
|
|
|
*/ |
|
|
|
public function __construct(SubscriptionsRepository $repo) |
|
|
|
{ |
|
|
|
$this->repo = $repo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show subscription list. |
|
|
|
* |
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function index(Request $request) |
|
|
|
{ |
|
|
|
$subscriptions = $this->repo->getSubscriptions( |
|
|
|
@ -32,6 +46,11 @@ class SubscriptionsController extends Controller |
|
|
|
return view('subscriptions.index', compact('subscriptions')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show subscription create page. |
|
|
|
* |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function create() |
|
|
|
{ |
|
|
|
$projects = $this->repo->getProjectsList(); |
|
|
|
@ -40,6 +59,12 @@ class SubscriptionsController extends Controller |
|
|
|
return view('subscriptions.create', compact('projects', 'vendors')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Store new subscription to database. |
|
|
|
* |
|
|
|
* @param \App\Http\Requests\SubscriptionRequest $subscriptionCreateRequest |
|
|
|
* @return \Illuminate\Routing\Redirector |
|
|
|
*/ |
|
|
|
public function store(FormRequest $subscriptionCreateRequest) |
|
|
|
{ |
|
|
|
$subscriptionCreateRequest->approveFor(new Subscription()); |
|
|
|
@ -49,6 +74,12 @@ class SubscriptionsController extends Controller |
|
|
|
return redirect()->route('subscriptions.index'); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show a subscription detail. |
|
|
|
* |
|
|
|
* @param \App\Entities\Subscriptions\Subscription $subscription |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function show(Subscription $subscription) |
|
|
|
{ |
|
|
|
$pageTitle = $this->getPageTitle('detail', $subscription); |
|
|
|
@ -56,6 +87,12 @@ class SubscriptionsController extends Controller |
|
|
|
return view('subscriptions.show', compact('subscription', 'pageTitle')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show a subscription edit form. |
|
|
|
* |
|
|
|
* @param \App\Entities\Subscriptions\Subscription $subscription |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function edit(Subscription $subscription) |
|
|
|
{ |
|
|
|
$projects = $this->repo->getProjectsList(); |
|
|
|
@ -66,6 +103,13 @@ class SubscriptionsController extends Controller |
|
|
|
return view('subscriptions.edit', compact('subscription', 'projects', 'vendors', 'pageTitle')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Update a subscription on database. |
|
|
|
* |
|
|
|
* @param \App\Http\Requests\SubscriptionRequest $subscriptionUpdateRequest |
|
|
|
* @param \App\Entities\Subscriptions\Subscription $subscription |
|
|
|
* @return \Illuminate\Routing\Redirector |
|
|
|
*/ |
|
|
|
public function update(FormRequest $subscriptionUpdateRequest, Subscription $subscription) |
|
|
|
{ |
|
|
|
$subscriptionUpdateRequest->approveFor($subscription); |
|
|
|
@ -75,6 +119,13 @@ class SubscriptionsController extends Controller |
|
|
|
return redirect()->route('subscriptions.edit', $subscription->id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Delete a subscription from database. |
|
|
|
* |
|
|
|
* @param \App\Http\Requests\SubscriptionRequest $subscriptionDeleteRequest |
|
|
|
* @param \App\Entities\Subscriptions\Subscription $subscription |
|
|
|
* @return \Illuminate\Routing\Redirector |
|
|
|
*/ |
|
|
|
public function destroy(FormRequest $subscriptionDeleteRequest, Subscription $subscription) |
|
|
|
{ |
|
|
|
$subscriptionDeleteRequest->approveToDelete($subscription); |
|
|
|
@ -84,11 +135,23 @@ class SubscriptionsController extends Controller |
|
|
|
return redirect()->route('subscriptions.index'); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get subscription type list. |
|
|
|
* |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
private function getSubscriptionTypes() |
|
|
|
{ |
|
|
|
return Type::toArray(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get page title based on subscription page type. |
|
|
|
* |
|
|
|
* @param string $pageType |
|
|
|
* @param \App\Entities\Subscriptions\Subscription $subscription |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
private function getPageTitle($pageType, $subscription) |
|
|
|
{ |
|
|
|
return trans('subscription.'.$pageType).' - '.$subscription->name.' - '.$subscription->customer->name; |
|
|
|
|