Browse Source

Add author on some class docblocks

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
79a1e045bf
  1. 2
      app/Entities/BaseRepository.php
  2. 31
      app/Entities/EloquentRepository.php
  3. 7
      app/Entities/ReferenceAbstract.php
  4. 2
      app/Entities/Reports/ReportsRepository.php
  5. 2
      app/Exceptions/ReferenceKeyNotFoundException.php
  6. 5
      app/Policies/EventPolicy.php
  7. 5
      app/Policies/Partners/CustomerPolicy.php
  8. 5
      app/Policies/Partners/VendorPolicy.php
  9. 7
      app/Policies/Projects/ProjectPolicy.php
  10. 5
      app/Policies/UserPolicy.php
  11. 13
      app/Queries/AdminDashboardQuery.php
  12. 5
      app/Services/Facades/Option.php
  13. 4
      app/Services/InvoiceDraft/InvoiceDraft.php
  14. 6
      app/Services/InvoiceDraft/InvoiceDraftCollection.php
  15. 4
      app/Services/InvoiceDraft/Item.php
  16. 2
      app/Services/Option.php

2
app/Entities/BaseRepository.php

@ -10,6 +10,8 @@ use App\Entities\Users\User;
/** /**
* Base Repository Class * Base Repository Class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
abstract class BaseRepository extends EloquentRepository abstract class BaseRepository extends EloquentRepository
{ {

31
app/Entities/EloquentRepository.php

@ -6,8 +6,10 @@ use App\Exceptions\EntityNotFoundException;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
* Eloquent Repository Class
*/
* Eloquent Repository Class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
abstract class EloquentRepository abstract class EloquentRepository
{ {
protected $_paginate = 25; protected $_paginate = 25;
@ -26,7 +28,7 @@ abstract class EloquentRepository
public function getAll($q) public function getAll($q)
{ {
return $this->model->latest() return $this->model->latest()
->where('name','like','%'.$q.'%')
->where('name', 'like', '%'.$q.'%')
->paginate($this->_paginate); ->paginate($this->_paginate);
} }
@ -38,8 +40,9 @@ abstract class EloquentRepository
public function getBy($column, $value) public function getBy($column, $value)
{ {
$model = $this->model->newQuery()->where($column, $value)->get(); $model = $this->model->newQuery()->where($column, $value)->get();
if ($model->count() > 1)
if ($model->count() > 1) {
return $model; return $model;
}
return $model->first(); return $model->first();
} }
@ -47,8 +50,10 @@ abstract class EloquentRepository
public function requireById($id) public function requireById($id)
{ {
$model = $this->getById($id); $model = $this->getById($id);
if ( ! $model )
if (!$model) {
throw new EntityNotFoundException($id, $this->model->getTable()); throw new EntityNotFoundException($id, $this->model->getTable());
}
return $model; return $model;
} }
@ -59,12 +64,14 @@ abstract class EloquentRepository
public function create($data) public function create($data)
{ {
if ($data instanceof Model)
{
if ($data instanceof Model) {
return $this->storeEloquentModel($data); return $this->storeEloquentModel($data);
} else { } else {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if ($data[$key] == '') $data[$key] = null;
if ($data[$key] == '') {
$data[$key] = null;
}
} }
return $this->storeArray($data); return $this->storeArray($data);
} }
@ -73,7 +80,10 @@ abstract class EloquentRepository
public function update($data = [], $modelId) public function update($data = [], $modelId)
{ {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (!$data[$key]) $data[$key] = null;
if (!$data[$key]) {
$data[$key] = null;
}
} }
$model = $this->requireById($modelId); $model = $this->requireById($modelId);
@ -89,8 +99,7 @@ abstract class EloquentRepository
protected function storeEloquentModel(Model $model) protected function storeEloquentModel(Model $model)
{ {
if ($model->getDirty())
{
if ($model->getDirty()) {
return $model->save(); return $model->save();
} else { } else {
return $model->touch(); return $model->touch();

7
app/Entities/ReferenceAbstract.php

@ -5,6 +5,11 @@ namespace App\Entities;
use App\Exceptions\ReferenceKeyNotFoundException; use App\Exceptions\ReferenceKeyNotFoundException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
/**
* Base of References class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
abstract class ReferenceAbstract abstract class ReferenceAbstract
{ {
protected static $lists = []; protected static $lists = [];
@ -52,7 +57,7 @@ abstract class ReferenceAbstract
public static function getColorById($colorId) public static function getColorById($colorId)
{ {
if ( ! ! static::getById($colorId) && isset(static::$colors[$colorId])) {
if (!!static::getById($colorId) && isset(static::$colors[$colorId])) {
return static::$colors[$colorId]; return static::$colors[$colorId];
} }

2
app/Entities/Reports/ReportsRepository.php

@ -9,6 +9,8 @@ use DB;
/** /**
* Reports Repository Class * Reports Repository Class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class ReportsRepository extends BaseRepository class ReportsRepository extends BaseRepository
{ {

2
app/Exceptions/ReferenceKeyNotFoundException.php

@ -4,6 +4,8 @@ namespace App\Exceptions;
/** /**
* Reference Key Not Found Exception * Reference Key Not Found Exception
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class ReferenceKeyNotFoundException extends \RuntimeException class ReferenceKeyNotFoundException extends \RuntimeException
{} {}

5
app/Policies/EventPolicy.php

@ -6,6 +6,11 @@ use App\Entities\Users\Event;
use App\Entities\Users\User; use App\Entities\Users\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
/**
* Event model policy class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class EventPolicy class EventPolicy
{ {
use HandlesAuthorization; use HandlesAuthorization;

5
app/Policies/Partners/CustomerPolicy.php

@ -6,6 +6,11 @@ use App\Entities\Partners\Customer;
use App\Entities\Users\User; use App\Entities\Users\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
/**
* Customer model policy class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class CustomerPolicy class CustomerPolicy
{ {
use HandlesAuthorization; use HandlesAuthorization;

5
app/Policies/Partners/VendorPolicy.php

@ -6,6 +6,11 @@ use App\Entities\Partners\Vendor;
use App\Entities\Users\User; use App\Entities\Users\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
/**
* Vendor model policy class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class VendorPolicy class VendorPolicy
{ {
use HandlesAuthorization; use HandlesAuthorization;

7
app/Policies/Projects/ProjectPolicy.php

@ -6,6 +6,11 @@ use App\Entities\Projects\Project;
use App\Entities\Users\User; use App\Entities\Users\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
/**
* Project model policy class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class ProjectPolicy class ProjectPolicy
{ {
use HandlesAuthorization; use HandlesAuthorization;
@ -33,7 +38,7 @@ class ProjectPolicy
public function create(User $user, Project $project) public function create(User $user, Project $project)
{ {
// User can create a project if they owns an agency. // User can create a project if they owns an agency.
return true;
return true;
} }
/** /**

5
app/Policies/UserPolicy.php

@ -6,6 +6,11 @@ use App\Entities\Users\User;
use App\Entities\Users\User as Worker; use App\Entities\Users\User as Worker;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
/**
* User model policy class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class UserPolicy class UserPolicy
{ {
use HandlesAuthorization; use HandlesAuthorization;

13
app/Queries/AdminDashboardQuery.php

@ -9,6 +9,8 @@ use Carbon\Carbon;
/** /**
* AdminDashboardQuery * AdminDashboardQuery
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class AdminDashboardQuery class AdminDashboardQuery
{ {
@ -43,6 +45,12 @@ class AdminDashboardQuery
return Project::where('status_id', 4)->where('start_date', 'like', $year.'%')->count(); return Project::where('status_id', 4)->where('start_date', 'like', $year.'%')->count();
} }
/**
* Get current outstanding customer payment amount
*
* @param string|integer $year Year of queried payment records
* @return integer Amount of outstanding customer payment
*/
public function currentOutstandingCustomerPayment($year) public function currentOutstandingCustomerPayment($year)
{ {
// On Progress, Done, On Hold // On Progress, Done, On Hold
@ -64,6 +72,11 @@ class AdminDashboardQuery
return $oustandingPaymentTotal; return $oustandingPaymentTotal;
} }
/**
* Get list of customer subscriptions that expires on next 60 days
*
* @return \Illuminate\Support\Collection Collection of filtered subscriptions
*/
public function upcomingSubscriptionDueDatesList() public function upcomingSubscriptionDueDatesList()
{ {
$subscriptions = Subscription::get(); $subscriptions = Subscription::get();

5
app/Services/Facades/Option.php

@ -4,6 +4,11 @@ namespace App\Services\Facades;
use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\Facade;
/**
* Option facade class
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class Option extends Facade class Option extends Facade
{ {
protected static function getFacadeAccessor() { return 'option'; } protected static function getFacadeAccessor() { return 'option'; }

4
app/Services/InvoiceDraft/InvoiceDraft.php

@ -6,6 +6,8 @@ use App\Entities\Invoices\Invoice;
/** /**
* Invoice Draft. * Invoice Draft.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class InvoiceDraft class InvoiceDraft
{ {
@ -47,7 +49,7 @@ class InvoiceDraft
public function updateItem($itemKey, $newItemData) public function updateItem($itemKey, $newItemData)
{ {
if ( ! isset($this->items[$itemKey])) {
if (!isset($this->items[$itemKey])) {
return; return;
} }

6
app/Services/InvoiceDraft/InvoiceDraftCollection.php

@ -6,6 +6,8 @@ use Illuminate\Support\Collection;
/** /**
* InvoiceDraft Collection Class. * InvoiceDraft Collection Class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class InvoiceDraftCollection class InvoiceDraftCollection
{ {
@ -34,7 +36,7 @@ class InvoiceDraftCollection
public function add(InvoiceDraft $draft) public function add(InvoiceDraft $draft)
{ {
$content = $this->getContent();
$content = $this->getContent();
$draft->draftKey = str_random(10); $draft->draftKey = str_random(10);
$content->put($draft->draftKey, $draft); $content->put($draft->draftKey, $draft);
@ -56,7 +58,7 @@ class InvoiceDraftCollection
$content = $this->getContent(); $content = $this->getContent();
$content[$draftKey]->projectId = $draftAttributes['project_id']; $content[$draftKey]->projectId = $draftAttributes['project_id'];
$content[$draftKey]->notes = $draftAttributes['notes'];
$content[$draftKey]->notes = $draftAttributes['notes'];
$this->session->put($this->instance, $content); $this->session->put($this->instance, $content);

4
app/Services/InvoiceDraft/Item.php

@ -4,6 +4,8 @@ namespace App\Services\InvoiceDrafts;
/** /**
* Draft Item class. * Draft Item class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class Item class Item
{ {
@ -13,7 +15,7 @@ class Item
public function __construct(array $itemDetail) public function __construct(array $itemDetail)
{ {
$this->description = $itemDetail['description']; $this->description = $itemDetail['description'];
$this->amount = $itemDetail['amount'];
$this->amount = $itemDetail['amount'];
} }
public function updateAttribute(array $newItemData) public function updateAttribute(array $newItemData)

2
app/Services/Option.php

@ -6,6 +6,8 @@ use App\Entities\Options\Option as SiteOption;
/** /**
* Option Class (Site Option Service) * Option Class (Site Option Service)
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/ */
class Option class Option
{ {

Loading…
Cancel
Save