7 changed files with 104 additions and 150 deletions
-
38app/Entities/BaseRepository.php
-
52app/Entities/Subscriptions/SubscriptionsRepository.php
-
38app/Http/Controllers/Controller.php
-
8app/Http/Controllers/PaymentsController.php
-
2app/Http/Controllers/Projects/JobsController.php
-
64app/Http/Controllers/SubscriptionsController.php
-
28app/Http/Requests/SubscriptionRequest.php
@ -1,52 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Entities\Subscriptions; |
|
||||
|
|
||||
use App\Entities\BaseRepository; |
|
||||
|
|
||||
/** |
|
||||
* Subscriptions Repository Class. |
|
||||
*/ |
|
||||
class SubscriptionsRepository extends BaseRepository |
|
||||
{ |
|
||||
/** |
|
||||
* Subscription model. |
|
||||
* |
|
||||
* @var \App\Entities\Subscriptions\Subscription |
|
||||
*/ |
|
||||
protected $model; |
|
||||
|
|
||||
/** |
|
||||
* Create SubscriptionRepository class instance. |
|
||||
* |
|
||||
* @param \App\Entities\Subscriptions\Subscription $model |
|
||||
*/ |
|
||||
public function __construct(Subscription $model) |
|
||||
{ |
|
||||
parent::__construct($model); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get subscrioption list. |
|
||||
* |
|
||||
* @param string $q |
|
||||
* @param int $customerId |
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator |
|
||||
*/ |
|
||||
public function getSubscriptions($q, $customerId) |
|
||||
{ |
|
||||
return $this->model->orderBy('status_id', 'desc') |
|
||||
->orderBy('due_date') |
|
||||
->where(function ($query) use ($q, $customerId) { |
|
||||
if ($customerId) { |
|
||||
$query->where('customer_id', $customerId); |
|
||||
} |
|
||||
|
|
||||
if ($q) { |
|
||||
$query->where('name', 'like', '%'.$q.'%'); |
|
||||
} |
|
||||
}) |
|
||||
->with('customer', 'vendor') |
|
||||
->paginate($this->_paginate); |
|
||||
} |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue