Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #3

Merged
merged 1 commit into from Dec 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Expand Up @@ -19,7 +19,8 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
4 changes: 2 additions & 2 deletions app/Entities/BaseRepository.php
Expand Up @@ -9,13 +9,12 @@
use App\Entities\Users\User;

/**
* Base Repository Class
* Base Repository Class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
abstract class BaseRepository extends EloquentRepository
{

public function getCustomersList()
{
return Customer::orderBy('name')->pluck('name', 'id');
Expand All @@ -27,6 +26,7 @@ public function getCustomersAndVendorsList()
'Customer' => Customer::orderBy('name')->pluck('name', 'id')->all(),
'Vendor' => Vendor::orderBy('name')->pluck('name', 'id')->all(),
];

return $partners;
}

Expand Down
10 changes: 6 additions & 4 deletions app/Entities/EloquentRepository.php
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Eloquent Repository Class
* Eloquent Repository Class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
Expand Down Expand Up @@ -71,29 +71,30 @@ public function create($data)
if ($data[$key] == '') {
$data[$key] = null;
}

}

return $this->storeArray($data);
}
}

public function update($data = [], $modelId)
public function update($data, $modelId)
{
foreach ($data as $key => $value) {
if (!$data[$key]) {
$data[$key] = null;
}

}

$model = $this->requireById($modelId);
$model->update($data);

return $model;
}

public function delete($modelId)
{
$model = $this->requireById($modelId);

return $model->delete();
}

Expand All @@ -110,6 +111,7 @@ protected function storeArray($data)
{
$model = $this->getNewInstance($data);
$this->storeEloquentModel($model);

return $model;
}
}
1 change: 1 addition & 0 deletions app/Entities/Invoices/Invoice.php
Expand Up @@ -45,6 +45,7 @@ public function generateNewNumber()
return ++$lastInvoiceNo;
}
}

return $prefix.'001';
}

Expand Down
8 changes: 4 additions & 4 deletions app/Entities/Options/Option.php
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Database\Eloquent\Model;

class Option extends Model {

protected $fillable = ['key','value'];
class Option extends Model
{
protected $fillable = ['key', 'value'];
protected $table = 'site_options';
public $timestamps = false;
public $timestamps = false;
}
1 change: 0 additions & 1 deletion app/Entities/Payments/Payment.php
Expand Up @@ -2,7 +2,6 @@

namespace App\Entities\Payments;

use App\Entities\Payments\PaymentPresenter;
use App\Entities\Projects\Project;
use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;
Expand Down
2 changes: 1 addition & 1 deletion app/Entities/Payments/PaymentPresenter.php
Expand Up @@ -25,4 +25,4 @@ public function type()
{
return paymentTypes($this->entity->type_id);
}
}
}
2 changes: 1 addition & 1 deletion app/Entities/Payments/PaymentsRepository.php
Expand Up @@ -5,7 +5,7 @@
use App\Entities\BaseRepository;

/**
* Payments Repository Class
* Payments Repository Class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
Expand Down
4 changes: 0 additions & 4 deletions app/Entities/Projects/Job.php
Expand Up @@ -2,15 +2,12 @@

namespace App\Entities\Projects;

use App\Entities\Projects\JobPresenter;
use App\Entities\Projects\Project;
use App\Entities\Users\User;
use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class Job extends Model
{

use PresentableTrait;

protected $presenter = JobPresenter::class;
Expand All @@ -35,5 +32,4 @@ public function type()
{
return $this->type_id == 1 ? 'Project' : 'Additional';
}

}
1 change: 0 additions & 1 deletion app/Entities/Projects/JobPresenter.php
Expand Up @@ -20,5 +20,4 @@ public function projectJobsLink()
{
return link_to_route('projects.jobs.index', trans('project.jobs'), [$this->project_id]);
}

}
5 changes: 2 additions & 3 deletions app/Entities/Projects/JobsRepository.php
Expand Up @@ -3,7 +3,6 @@
namespace App\Entities\Projects;

use App\Entities\BaseRepository;
use App\Entities\Projects\Project;
use DB;

/**
Expand Down Expand Up @@ -40,6 +39,7 @@ public function requireProjectById($projectId)
public function createJob($jobData, $projectId)
{
$jobData['project_id'] = $projectId;

return $this->storeArray($jobData);
}

Expand Down Expand Up @@ -77,13 +77,12 @@ public function requireTaskById($taskId)
return Task::findOrFail($taskId);
}

public function update($jobData = [], $jobId)
public function update($jobData, $jobId)
{
foreach ($jobData as $key => $value) {
if (!$jobData[$key]) {
$jobData[$key] = null;
}

}

$jobData['price'] = str_replace('.', '', $jobData['price']);
Expand Down
3 changes: 0 additions & 3 deletions app/Entities/Projects/Project.php
Expand Up @@ -5,8 +5,6 @@
use App\Entities\Invoices\Invoice;
use App\Entities\Partners\Customer;
use App\Entities\Payments\Payment;
use App\Entities\Projects\ProjectPresenter;
use App\Entities\Projects\Task;
use App\Entities\Subscriptions\Subscription;
use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;
Expand Down Expand Up @@ -131,5 +129,4 @@ public function getJobList($jobType)
->with('worker', 'tasks')
->get();
}

}
1 change: 0 additions & 1 deletion app/Entities/Projects/ProjectPresenter.php
Expand Up @@ -35,5 +35,4 @@ public function workDuration()

return $workDuration.' Hari';
}

}
7 changes: 4 additions & 3 deletions app/Entities/Projects/ProjectsRepository.php
Expand Up @@ -8,7 +8,7 @@
use ProjectStatus;

/**
* Projects Repository Class
* Projects Repository Class.
*/
class ProjectsRepository extends BaseRepository
{
Expand All @@ -29,7 +29,6 @@ public function getProjects($q, $statusId)
if ($statusId && in_array($statusId, $statusIds)) {
$query->where('status_id', $statusId);
}

})
->withCount('payments')
->with('customer')
Expand All @@ -50,6 +49,7 @@ public function create($projectData)

$project = $this->storeArray($projectData);
DB::commit();

return $project;
}

Expand All @@ -60,7 +60,7 @@ public function getStatusName($statusId)

public function createNewCustomer($customerName, $customerEmail)
{
$newCustomer = new Customer;
$newCustomer = new Customer();
$newCustomer->name = $customerName;
$newCustomer->email = $customerEmail;
$newCustomer->save();
Expand Down Expand Up @@ -88,6 +88,7 @@ public function delete($projectId)
$project->delete();

DB::commit();

return 'deleted';
}

Expand Down
2 changes: 1 addition & 1 deletion app/Entities/Projects/Status.php
Expand Up @@ -41,7 +41,7 @@ public static function getNameById($singleId)

public static function getIconById($singleId)
{
if (!!static::getById($singleId) && isset(static::$icons[$singleId])) {
if ((bool) static::getById($singleId) && isset(static::$icons[$singleId])) {
return static::$icons[$singleId];
}

Expand Down
3 changes: 0 additions & 3 deletions app/Entities/Projects/Task.php
Expand Up @@ -2,13 +2,11 @@

namespace App\Entities\Projects;

use App\Entities\Projects\TaskPresenter;
use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class Task extends Model
{

use PresentableTrait;

protected $presenter = TaskPresenter::class;
Expand All @@ -18,5 +16,4 @@ public function job()
{
return $this->belongsTo(Job::class, 'project_id');
}

}
3 changes: 2 additions & 1 deletion app/Entities/Projects/TasksRepository.php
Expand Up @@ -5,7 +5,7 @@
use App\Entities\BaseRepository;

/**
* Tasks Repository Class
* Tasks Repository Class.
*/
class TasksRepository extends BaseRepository
{
Expand All @@ -19,6 +19,7 @@ public function __construct(Task $model)
public function createTask($taskData, $jobId)
{
$taskData['job_id'] = $jobId;

return $this->storeArray($taskData);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Entities/ReferenceAbstract.php
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Arr;

/**
* Base of References class
* Base of References class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
Expand Down Expand Up @@ -57,7 +57,7 @@ public static function colors()

public static function getColorById($colorId)
{
if (!!static::getById($colorId) && isset(static::$colors[$colorId])) {
if ((bool) static::getById($colorId) && isset(static::$colors[$colorId])) {
return static::$colors[$colorId];
}

Expand Down
18 changes: 9 additions & 9 deletions app/Entities/Reports/ReportsRepository.php
Expand Up @@ -8,7 +8,7 @@
use DB;

/**
* Reports Repository Class
* Reports Repository Class.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
Expand All @@ -31,9 +31,9 @@ public function getDailyReports($date, $q)

public function getMonthlyReports($year, $month)
{
$rawQuery = "date, count(`id`) as count";
$rawQuery .= ", sum(if(in_out = 1, amount, 0)) AS cashin";
$rawQuery .= ", sum(if(in_out = 0, amount, 0)) AS cashout";
$rawQuery = 'date, count(`id`) as count';
$rawQuery .= ', sum(if(in_out = 1, amount, 0)) AS cashin';
$rawQuery .= ', sum(if(in_out = 0, amount, 0)) AS cashout';

$reportsData = DB::table('payments')->select(DB::raw($rawQuery))
->where(DB::raw('YEAR(date)'), $year)
Expand All @@ -54,10 +54,10 @@ public function getMonthlyReports($year, $month)

public function getYearlyReports($year)
{
$rawQuery = "MONTH(date) as month";
$rawQuery .= ", count(`id`) as count";
$rawQuery .= ", sum(if(in_out = 1, amount, 0)) AS cashin";
$rawQuery .= ", sum(if(in_out = 0, amount, 0)) AS cashout";
$rawQuery = 'MONTH(date) as month';
$rawQuery .= ', count(`id`) as count';
$rawQuery .= ', sum(if(in_out = 1, amount, 0)) AS cashin';
$rawQuery .= ', sum(if(in_out = 0, amount, 0)) AS cashout';

$reportsData = DB::table('payments')->select(DB::raw($rawQuery))
->where(DB::raw('YEAR(date)'), $year)
Expand All @@ -80,9 +80,9 @@ public function getCurrentCredits()
{
// On Progress, Done, On Hold
$projects = Project::whereIn('status_id', [2, 3, 6])->with('payments', 'customer')->get();

return $projects->filter(function ($project) {
return $project->cashInTotal() < $project->project_value;
})->values();
}

}
4 changes: 2 additions & 2 deletions app/Entities/Subscriptions/SubscriptionPresenter.php
Expand Up @@ -8,6 +8,6 @@ class SubscriptionPresenter extends Presenter
{
public function customerNameAndEmail()
{
return $this->customer_id ? $this->customer->name . ' (' . $this->customer->email . ')' : '-';
return $this->customer_id ? $this->customer->name.' ('.$this->customer->email.')' : '-';
}
}
}
3 changes: 1 addition & 2 deletions app/Entities/Subscriptions/SubscriptionsRepository.php
Expand Up @@ -5,7 +5,7 @@
use App\Entities\BaseRepository;

/**
* Subscriptions Repository Class
* Subscriptions Repository Class.
*/
class SubscriptionsRepository extends BaseRepository
{
Expand All @@ -28,7 +28,6 @@ public function getSubscriptions($q, $customerId)
if ($q) {
$query->where('name', 'like', '%'.$q.'%');
}

})
->with('customer', 'vendor')
->paginate($this->_paginate);
Expand Down