Merge pull request #1696 from akaunting/2.1-dev

2.1 dev
This commit is contained in:
Cüneyt Şentürk 2020-12-26 21:12:46 +03:00 committed by GitHub
commit 970df49388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
731 changed files with 44430 additions and 41513 deletions

View File

@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
php: ['7.2', '7.3', '7.4']
php: ['7.3', '7.4']
steps:
- name: Checkout code

2
.gitignore vendored
View File

@ -95,3 +95,5 @@ _ide_helper_models.php
modules/*
!modules/OfflinePayments
!modules/PaypalStandard
!modules/BC21
.laravelstatsrc

View File

@ -16,7 +16,7 @@ Akaunting is a free, open source and online accounting software designed for sma
## Requirements
* PHP 7.2.5 or higher
* PHP 7.3 or higher
* Database (eg: MySQL, PostgreSQL, SQLite)
* Web Server (eg: Apache, Nginx, IIS)
* [Other libraries](https://akaunting.com/docs/requirements)

View File

@ -76,7 +76,7 @@ abstract class BulkAction
$items = $this->getSelectedRecords($request);
foreach ($items as $item) {
$item->enabled = 1;
$item->enabled = true;
$item->save();
}
}
@ -93,7 +93,7 @@ abstract class BulkAction
$items = $this->getSelectedRecords($request);
foreach ($items as $item) {
$item->enabled = 0;
$item->enabled = false;
$item->save();
}
}

View File

@ -1,196 +0,0 @@
<?php
namespace App\Abstracts;
use App\Abstracts\Model;
use App\Models\Setting\Tax;
use App\Traits\Currencies;
use App\Traits\DateTime;
use App\Traits\Media;
use App\Traits\Recurring;
use Bkwld\Cloner\Cloneable;
abstract class DocumentModel extends Model
{
use Cloneable, Currencies, DateTime, Media, Recurring;
public function totals_sorted()
{
return $this->totals()->orderBy('sort_order');
}
public function scopeDue($query, $date)
{
return $query->whereDate('due_at', '=', $date);
}
public function scopeAccrued($query)
{
return $query->whereNotIn('status', ['draft', 'cancelled']);
}
public function scopePaid($query)
{
return $query->where('status', '=', 'paid');
}
public function scopeNotPaid($query)
{
return $query->where('status', '<>', 'paid');
}
/**
* Get the current balance.
*
* @return string
*/
public function getAttachmentAttribute($value)
{
if (!empty($value) && !$this->hasMedia('attachment')) {
return $value;
} elseif (!$this->hasMedia('attachment')) {
return false;
}
return $this->getMedia('attachment')->last();
}
/**
* Get the discount percentage.
*
* @return string
*/
public function getDiscountAttribute()
{
$percent = 0;
$discount = $this->totals->where('code', 'discount')->makeHidden('title')->pluck('amount')->first();
if ($discount) {
$sub_total = $this->totals->where('code', 'sub_total')->makeHidden('title')->pluck('amount')->first();
$percent = number_format((($discount * 100) / $sub_total), 0);
}
return $percent;
}
/**
* Get the paid amount.
*
* @return string
*/
public function getPaidAttribute()
{
if (empty($this->amount)) {
return false;
}
$paid = 0;
$reconciled = $reconciled_amount = 0;
$code = $this->currency_code;
$rate = config('money.' . $code . '.rate');
$precision = config('money.' . $code . '.precision');
if ($this->transactions->count()) {
foreach ($this->transactions as $item) {
$amount = $item->amount;
if ($code != $item->currency_code) {
$amount = $this->convertBetween($amount, $item->currency_code, $item->currency_rate, $code, $rate);
}
$paid += $amount;
if ($item->reconciled) {
$reconciled_amount = +$amount;
}
}
}
if (bccomp(round($this->amount, $precision), round($reconciled_amount, $precision), $precision) === 0) {
$reconciled = 1;
}
$this->setAttribute('reconciled', $reconciled);
return round($paid, $precision);
}
/**
* Get the status label.
*
* @return string
*/
public function getStatusLabelAttribute()
{
switch ($this->status) {
case 'paid':
$label = 'success';
break;
case 'partial':
$label = 'info';
break;
case 'sent':
case 'received':
$label = 'danger';
break;
case 'viewed':
$label = 'warning';
break;
case 'cancelled':
$label = 'dark';
break;
default:
$label = 'primary';
break;
}
return $label;
}
/**
* Get the amount without tax.
*
* @return string
*/
public function getAmountWithoutTaxAttribute()
{
$amount = $this->amount;
$this->totals->where('code', 'tax')->each(function ($total) use(&$amount) {
$tax = Tax::name($total->name)->first();
if (!empty($tax) && ($tax->type == 'withholding')) {
return;
}
$amount -= $total->amount;
});
return $amount;
}
/**
* Convert amount to double.
*
* @param string $value
* @return void
*/
public function setAmountAttribute($value)
{
$this->attributes['amount'] = (double) $value;
}
/**
* Convert currency rate to double.
*
* @param string $value
* @return void
*/
public function setCurrencyRateAttribute($value)
{
$this->attributes['currency_rate'] = (double) $value;
}
}

12
app/Abstracts/Event.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace App\Abstracts;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
abstract class Event
{
use Dispatchable, InteractsWithSockets, SerializesModels;
}

View File

@ -34,7 +34,7 @@ abstract class Export implements FromCollection, ShouldAutoSize, WithHeadings, W
{
$map = [];
$date_fields = ['paid_at', 'invoiced_at', 'billed_at', 'due_at', 'issued_at', 'created_at'];
$date_fields = ['paid_at', 'invoiced_at', 'billed_at', 'due_at', 'issued_at', 'created_at', 'transferred_at'];
$evil_chars = ['=', '+', '-', '@'];

40
app/Abstracts/Factory.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace App\Abstracts;
use App\Models\Auth\User;
use App\Models\Common\Company;
use App\Traits\Jobs;
use Illuminate\Database\Eloquent\Factories\Factory as BaseFactory;
use Illuminate\Database\Eloquent\Model as EloquentModel;
abstract class Factory extends BaseFactory
{
use Jobs;
/**
* @var Company
*/
protected $company;
/**
* @var User|EloquentModel|object|null
*/
protected $user;
public function __construct(...$arguments)
{
parent::__construct(...$arguments);
$this->user = User::first();
$this->company = $this->user->companies()->first();
session(['company_id' => $this->company->id]);
setting()->setExtraColumns(['company_id' => $this->company->id]);
}
public function getCompanyUsers()
{
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
}
}

View File

@ -2,13 +2,27 @@
namespace App\Abstracts\Http;
use App\Traits\Jobs;
use App\Traits\Permissions;
use App\Traits\Relationships;
use Dingo\Api\Exception\ResourceException;
use Dingo\Api\Routing\Helpers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
abstract class ApiController extends Controller
abstract class ApiController extends BaseController
{
use Helpers;
use AuthorizesRequests, Jobs, Helpers, Permissions, Relationships, ValidatesRequests;
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
$this->assignPermissionsToController();
}
/**
* Create the response for when a request fails validation.

View File

@ -2,7 +2,9 @@
namespace App\Abstracts\Http;
use App\Abstracts\Http\Response;
use App\Traits\Jobs;
use App\Traits\Permissions;
use App\Traits\Relationships;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
@ -10,73 +12,17 @@ use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Routing\Route;
use Illuminate\Support\Str;
abstract class Controller extends BaseController
{
use AuthorizesRequests, Jobs, Relationships, ValidatesRequests;
use AuthorizesRequests, Jobs, Permissions, Relationships, ValidatesRequests;
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
$this->setPermissions();
}
/**
* Assign permissions to methods.
*
* @return void
*/
public function setPermissions()
{
// No need to check for permission in console
if (app()->runningInConsole()) {
return;
}
$route = app(Route::class);
// Get the controller array
$arr = array_reverse(explode('\\', explode('@', $route->getAction()['uses'])[0]));
$controller = '';
// Add module
if (isset($arr[3]) && isset($arr[4])) {
if (strtolower($arr[4]) == 'modules') {
$controller .= Str::kebab($arr[3]) . '-';
} elseif (isset($arr[5]) && (strtolower($arr[5]) == 'modules')) {
$controller .= Str::kebab($arr[4]) . '-';
}
}
// Add folder
if (strtolower($arr[1]) != 'controllers') {
$controller .= Str::kebab($arr[1]) . '-';
}
// Add file
$controller .= Str::kebab($arr[0]);
// Skip ACL
$skip = ['portal-dashboard'];
if (in_array($controller, $skip)) {
return;
}
// App\Http\Controllers\FooBar -->> foo-bar
// App\Http\Controllers\FooBar\Main -->> foo-bar-main
// Modules\Blog\Http\Controllers\Posts -->> blog-posts
// Modules\Blog\Http\Controllers\Portal\Posts -->> blog-portal-posts
// Add CRUD permission check
$this->middleware('permission:create-' . $controller)->only('create', 'store', 'duplicate', 'import');
$this->middleware('permission:read-' . $controller)->only('index', 'show', 'edit', 'export');
$this->middleware('permission:update-' . $controller)->only('update', 'enable', 'disable');
$this->middleware('permission:delete-' . $controller)->only('destroy');
$this->assignPermissionsToController();
}
/**
@ -99,4 +45,25 @@ abstract class Controller extends BaseController
return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
}
/**
* Generate a response based on request type like HTML, JSON, or anything else.
*
* @param string $view
* @param array $data
*
* @return \Illuminate\Http\Response
*/
public function response($view, $data = [])
{
$class_name = str_replace('Controllers', 'Responses', (new \ReflectionClass($this))->getName());
if (class_exists($class_name)) {
$response = new $class_name($view, $data);
} else {
$response = new class($view, $data) extends Response {};
}
return $response;
}
}

View File

@ -2,9 +2,9 @@
namespace App\Abstracts\Http;
use App\Events\Sale\PaymentReceived;
use App\Events\Document\PaymentReceived;
use App\Http\Requests\Portal\InvoicePayment as PaymentRequest;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\URL;
use Monolog\Logger;
@ -41,15 +41,15 @@ abstract class PaymentController extends BaseController
});
}
public function show(Invoice $invoice, PaymentRequest $request)
public function show(Document $document, PaymentRequest $request)
{
$this->setContactFirstLastName($invoice);
$this->setContactFirstLastName($document);
$confirm_url = $this->getConfirmUrl($invoice);
$confirm_url = $this->getConfirmUrl($document);
$html = view('partials.portal.payment_method.' . $this->type, [
'setting' => $this->setting,
'invoice' => $invoice,
'invoice' => $document,
'confirm_url' => $confirm_url,
])->render();
@ -62,12 +62,12 @@ abstract class PaymentController extends BaseController
]);
}
public function signed(Invoice $invoice, PaymentRequest $request)
public function signed(Document $document, PaymentRequest $request)
{
return $this->show($invoice, $request);
return $this->show($document, $request);
}
public function cancel(Invoice $invoice, $force_redirect = false)
public function cancel(Document $invoice, $force_redirect = false)
{
$message = trans('messages.warning.payment_cancel', ['method' => setting($this->alias . '.name')]);
@ -164,6 +164,7 @@ abstract class PaymentController extends BaseController
$request['amount'] = $invoice->amount;
$request['payment_method'] = $this->alias;
$request['reference'] = $this->getReference($invoice);
$request['type'] = 'income';
event(new PaymentReceived($invoice, $request));
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Abstracts\Http;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
abstract class Response implements Responsable
{
protected $accepts = ['json', 'rss'];
protected $view;
protected $data;
public function __construct($view, $data)
{
$this->view = $view;
$this->data = $data;
}
public function toJson()
{
return response()->json([
'success' => true,
'error' => false,
'data' => Arr::first($this->data),
'message' => '',
]);
}
public function toHtml()
{
return view($this->view, $this->data);
}
public function toResponse($request)
{
foreach ($this->accepts as $accept) {
$request_method = 'expects' . Str::studly($accept);
$response_method = 'to' . Str::studly($accept);
if (!method_exists($request, $request_method) || !method_exists($this, $response_method)) {
continue;
}
if ($request->{$request_method}()) {
return $this->{$response_method}();
}
}
return $this->toHtml();
}
}

View File

@ -39,7 +39,7 @@ abstract class Import implements ToModel, SkipsOnError, SkipsOnFailure, WithBatc
$row['reconciled'] = (int) $row['reconciled'];
}
$date_fields = ['paid_at', 'invoiced_at', 'billed_at', 'due_at', 'issued_at', 'created_at'];
$date_fields = ['paid_at', 'invoiced_at', 'billed_at', 'due_at', 'issued_at', 'created_at', 'transferred_at'];
foreach ($date_fields as $date_field) {
if (!isset($row[$date_field])) {
continue;

View File

@ -22,6 +22,11 @@ abstract class Model extends Eloquent
'enabled' => 'boolean',
];
public static function observe($classes)
{
parent::observe($classes);
}
/**
* The "booting" method of the model.
*
@ -44,6 +49,18 @@ abstract class Model extends Eloquent
return $this->belongsTo('App\Models\Common\Company');
}
/**
* Scope to only include company data.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAllCompanies($query)
{
return $query->withoutGlobalScope(Company::class);
}
/**
* Scope to only include company data.
*
@ -70,9 +87,16 @@ abstract class Model extends Eloquent
$request = request();
$search = $request->get('search');
$query->usingSearchString($search)->sortable($sort);
if ($request->expectsJson()) {
return $query->get();
}
$limit = $request->get('limit', setting('default.list_limit', '25'));
return $query->usingSearchString($search)->sortable($sort)->paginate($limit);
return $query->paginate($limit);
}
/**

View File

@ -12,7 +12,7 @@ use App\Events\Report\RowsShowing;
use App\Exports\Common\Reports as Export;
use App\Models\Banking\Transaction;
use App\Models\Common\Report as Model;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Traits\Charts;
use App\Traits\DateTime;
use App\Utilities\Chartjs;
@ -355,7 +355,7 @@ abstract class Report
$amount = $item->getAmountConvertedToDefault(false, $with_tax);
$type = (($item instanceof Invoice) || (($item instanceof Transaction) && ($item->type == 'income'))) ? 'income' : 'expense';
$type = ($item->type === Document::INVOICE_TYPE || $item->type === 'income') ? 'income' : 'expense';
if (($check_type == false) || ($type == 'income')) {
$this->row_values[$table][$item->$id_field][$date] += $amount;

View File

@ -0,0 +1,34 @@
<?php
namespace App\Abstracts\View\Components;
use Illuminate\View\Component;
use Illuminate\Support\Str;
abstract class DocumentForm extends Component
{
public $type;
public $documents;
public $bulkActions;
/** @var bool */
public $hideBulkAction;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$type, $documents = [], $bulkActions = [],
bool $hideBulkAction = false
) {
$this->type = $type;
$this->documents = $documents;
$this->bulkActions = $bulkActions;
$this->hideBulkAction = $hideBulkAction;
}
}

View File

@ -0,0 +1,933 @@
<?php
namespace App\Abstracts\View\Components;
use Illuminate\View\Component;
use Illuminate\Support\Str;
use App\Events\Common\BulkActionsAdding;
abstract class DocumentIndex extends Component
{
/** @var string */
public $type;
public $documents;
/** @var string */
public $page;
/** @var string */
public $docsPath;
/** @var bool */
public $checkCreatePermission;
/** @var string */
public $createPermission;
/** @var string */
public $createRoute;
/** @var string */
public $importRoute;
/** @var array */
public $importRouteParameters;
/** @var string */
public $exportRoute;
/** @var bool */
public $hideCreate;
/** @var bool */
public $hideImport;
/** @var bool */
public $hideExport;
/* -- Card Header Start -- */
/** @var string */
public $textBulkAction;
/** @var string */
public $bulkActionClass;
/** @var array */
public $bulkActions;
/** @var array */
public $bulkActionRouteParameters;
/** @var string */
public $formCardHeaderRoute;
/** @var bool */
public $hideBulkAction;
/** @var string */
public $classBulkAction;
/** @var string */
public $searchStringModel;
/** @var bool */
public $hideSearchString;
/* -- Card Header End -- */
/* -- Card Body Start -- */
/** @var string */
public $textDocumentNumber;
/** @var string */
public $textContactName;
/** @var string */
public $textIssueAt;
/** @var string */
public $textDueAt;
/** @var string */
public $textDocumentStatus;
/** @var bool */
public $checkButtonReconciled;
/** @var bool */
public $checkButtonCancelled;
/** @var bool */
public $hideDocumentNumber;
/** @var string */
public $classDocumentNumber;
/** @var bool */
public $hideContactName;
/** @var string */
public $classContactName;
/** @var bool */
public $hideAmount;
/** @var string */
public $classAmount;
/** @var bool */
public $hideIssuedAt;
/** @var string */
public $classIssuedAt;
/** @var bool */
public $hideDueAt;
/** @var string */
public $classDueAt;
/** @var bool */
public $hideStatus;
/** @var string */
public $classStatus;
/** @var bool */
public $hideActions;
/** @var string */
public $routeButtonShow;
/** @var string */
public $routeButtonEdit;
/** @var string */
public $routeButtonDuplicate;
/** @var string */
public $routeButtonCancelled;
/** @var string */
public $routeButtonDelete;
/** @var bool */
public $hideButtonShow;
/** @var bool */
public $hideButtonEdit;
/** @var bool */
public $hideButtonDuplicate;
/** @var bool */
public $hideButtonCancel;
/** @var bool */
public $hideButtonDelete;
/** @var string */
public $permissionDocumentCreate;
/** @var string */
public $permissionDocumentUpdate;
/** @var string */
public $permissionDocumentDelete;
/* -- Card Body End -- */
public $limits;
public $hideEmptyPage;
public $classActions;
public $class_count;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $documents = [], string $page = '', string $docsPath = '', $limits = [], $hideEmptyPage = false,
bool $checkCreatePermission = true, string $createPermission = '', string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false, // Advanced
string $textBulkAction = '', array $bulkActions = [], string $bulkActionClass = '', array $bulkActionRouteParameters = [], string $formCardHeaderRoute = '', string $searchStringModel = '',
bool $hideBulkAction = false, bool $hideSearchString = false,
string $classActions = '', string $classBulkAction = '', string $classDocumentNumber = '', string $classContactName = '', string $classIssuedAt = '', string $classDueAt = '', string $classStatus = '',
string $textDocumentNumber = '', string $textContactName = '', string $classAmount = '', string $textIssueAt = '', string $textDueAt = '', string $textDocumentStatus = '',
bool $checkButtonReconciled = true, bool $checkButtonCancelled = true,
string $routeButtonShow = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonCancelled = '', string $routeButtonDelete = '',
bool $hideDocumentNumber = false, bool $hideContactName = false, bool $hideAmount = false, bool $hideIssuedAt = false, bool $hideDueAt = false, bool $hideStatus = false, bool $hideActions = false,
bool $hideButtonShow = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonCancel = false, bool $hideButtonDelete = false,
string $permissionDocumentCreate = '', string $permissionDocumentUpdate = '', string $permissionDocumentDelete = ''
) {
$this->type = $type;
$this->documents = $documents;
$this->page = $this->getPage($type, $page);
$this->docsPath = $this->getDocsPath($type, $docsPath);
$this->hideEmptyPage = $hideEmptyPage;
/* -- Top Buttons Start -- */
$this->checkCreatePermission = $checkCreatePermission;
$this->createPermission = $this->getCreatePermission($type, $createPermission);
$this->createRoute = $this->getCreateRoute($type, $createRoute);
$this->importRoute = $this->getImportRoute($importRoute);
$this->importRouteParameters = $this->getImportRouteParameters($type, $importRouteParameters);
$this->exportRoute = $this->getExportRoute($type, $exportRoute);
$this->hideCreate = $hideCreate;
$this->hideImport = $hideImport;
$this->hideExport = $hideExport;
/* -- Top Buttons End -- */
/* -- Card Header Start -- */
$this->textBulkAction = $this->getTextBulkAction($type, $textBulkAction);
$this->bulkActionClass = $bulkActionClass;
$this->bulkActions = $this->getBulkActions($type, $bulkActions, $bulkActionClass);
$this->bulkActionRouteParameters = $this->getBulkActionRouteParameters($type, $bulkActionRouteParameters);
$this->formCardHeaderRoute = $this->getRoute($type, $formCardHeaderRoute);
$this->searchStringModel = $this->getSearchStringModel($type, $searchStringModel);
$this->hideBulkAction = $hideBulkAction;
$this->hideSearchString = $hideSearchString;
/* -- Card Header End -- */
/* -- Card Body Start -- */
$this->textDocumentNumber = $this->getTextDocumentNumber($textDocumentNumber);
$this->textContactName = $this->getTextContactName($type, $textContactName);
$this->textIssueAt = $this->getTextIssueAt($type, $textIssueAt);
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
$this->textDocumentStatus = $this->getTextDocumentStatus($type, $textDocumentStatus);
$this->checkButtonReconciled = $checkButtonReconciled;
$this->checkButtonCancelled = $checkButtonCancelled;
$this->routeButtonShow = $this->getRouteButtonShow($type, $routeButtonShow);
$this->routeButtonEdit = $this->getRouteButtonEdit($type, $routeButtonEdit);
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($type, $routeButtonDuplicate);
$this->routeButtonCancelled = $this->getRouteButtonCancelled($type, $routeButtonCancelled);
$this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete);
$this->hideBulkAction = $hideBulkAction;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->hideContactName = $hideContactName;
$this->hideAmount = $hideAmount;
$this->hideIssuedAt = $hideIssuedAt;
$this->hideDueAt = $hideDueAt;
$this->hideStatus = $hideStatus;
$this->hideActions = $hideActions;
$this->class_count = 12;
$this->calculateClass();
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
$this->classDocumentNumber = $this->getClassDocumentNumber($type, $classDocumentNumber);
$this->classContactName = $this->getClassContactName($type, $classContactName);
$this->classAmount = $this->getClassAmount($type, $classAmount);
$this->classIssuedAt = $this->getclassIssuedAt($type, $classIssuedAt);
$this->classDueAt = $this->getClassDueAt($type, $classDueAt);
$this->classStatus = $this->getClassStatus($type, $classStatus);
$this->classActions = $this->getClassActions($type, $classActions);
$this->hideButtonShow = $hideButtonShow;
$this->hideButtonEdit = $hideButtonEdit;
$this->hideButtonDuplicate = $hideButtonDuplicate;
$this->hideButtonCancel = $hideButtonCancel;
$this->hideButtonDelete = $hideButtonDelete;
$this->permissionDocumentCreate = $this->getPermissionDocumentCreate($type, $permissionDocumentCreate);
$this->permissionDocumentUpdate = $this->getPermissionDocumentUpdate($type, $permissionDocumentUpdate);
$this->permissionDocumentDelete = $this->getPermissionDocumentDelete($type, $permissionDocumentDelete);
/* -- Card Body End -- */
$this->limits = ($limits) ? $limits : ['10' => '10', '25' => '25', '50' => '50', '100' => '100'];
}
protected function getPage($type, $page)
{
if (!empty($page)) {
return $page;
}
return Str::plural($type, 2);
}
protected function getDocsPath($type, $docsPath)
{
if (!empty($docsPath)) {
return $docsPath;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$docsPath = 'sales/invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$docsPath = 'purchases/bills';
break;
}
return $docsPath;
}
protected function getCreatePermission($type, $createPermission)
{
if (!empty($createPermission)) {
return $createPermission;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$createPermission = 'create-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$createPermission = 'create-purchases-bills';
break;
}
return $createPermission;
}
protected function getCreateRoute($type, $createRoute)
{
if (!empty($createRoute)) {
return $createRoute;
}
$page = Str::plural($type, 2);
$route = $page . '.create';
try {
route($route);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getImportRoute($importRoute)
{
if (!empty($importRoute)) {
return $importRoute;
}
$route = 'import.create';
return $route;
}
protected function getImportRouteParameters($type, $importRouteParameters)
{
if (!empty($importRouteParameters)) {
return $importRouteParameters;
}
$importRouteParameters = [
'group' => ($type == 'invoice') ? 'sales' : 'purchases',
'type' => Str::plural($type, 2)
];
return $importRouteParameters;
}
protected function getExportRoute($type, $exportRoute)
{
if (!empty($exportRoute)) {
return $exportRoute;
}
$page = Str::plural($type, 2);
$route = $page . '.export';
try {
route($route);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getRoute($type, $formCardHeaderRoute)
{
if (!empty($formCardHeaderRoute)) {
return $formCardHeaderRoute;
}
$page = Str::plural($type, 2);
$route = $page . '.index';
try {
route($route);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getSearchStringModel($type, $searchStringModel)
{
if (!empty($searchStringModel)) {
return $searchStringModel;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$searchStringModel = 'App\Models\Sale\Invoice';
break;
case 'bill':
case 'expense':
case 'purchase':
$searchStringModel = 'App\Models\Purchase\Bill';
break;
}
return $searchStringModel;
}
protected function getTextBulkAction($type, $textBulkAction)
{
if (!empty($textBulkAction)) {
return $textBulkAction;
}
$textBulkAction = 'general.' . Str::plural($type, 2);
return $textBulkAction;
}
protected function getBulkActions($type, $bulkActions, $bulkActionClass)
{
if (!empty($bulkActions)) {
return $bulkActions;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$bulkActionClass = 'App\BulkActions\Sales\Invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$bulkActionClass = 'App\BulkActions\Purchases\Bills';
break;
}
if (class_exists($bulkActionClass)) {
event(new BulkActionsAdding(app($bulkActionClass)));
$bulkActions = app($bulkActionClass)->actions;
} else {
$b = new \stdClass();
$b->actions = [];
event(new BulkActionsAdding($b));
$bulkActions = $b->actions;
}
return $bulkActions;
}
protected function getBulkActionRouteParameters($type, $bulkActionRouteParameters)
{
if (!empty($bulkActionRouteParameters)) {
return $bulkActionRouteParameters;
}
$bulkActionRouteParameters = [
'group' => ($type == 'invoice') ? 'sales' : 'purchases',
'type' => Str::plural($type, 2)
];
return $bulkActionRouteParameters;
}
protected function getClassBulkAction($type, $classBulkAction)
{
if (!empty($classBulkAction)) {
return $classBulkAction;
}
return 'col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block';
}
protected function getTextDocumentNumber($textDocumentNumber)
{
if (!empty($textDocumentNumber)) {
return $textDocumentNumber;
}
return 'general.numbers';
}
protected function getClassDocumentNumber($type, $classDocumentNumber)
{
if (!empty($classDocumentNumber)) {
return $classDocumentNumber;
}
if ($classDocumentNumber = $this->getClass('classDocumentNumber')) {
return $classDocumentNumber;
}
return 'col-md-2 col-lg-1 col-xl-1 d-none d-md-block';
}
protected function getTextContactName($type, $textContactName)
{
if (!empty($textContactName)) {
return $textContactName;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textContactName = 'general.customers';
break;
case 'bill':
case 'expense':
case 'purchase':
$textContactName = 'general.vendors';
break;
}
return $textContactName;
}
protected function getClassContactName($type, $classContactName)
{
if (!empty($classContactName)) {
return $classContactName;
}
if ($classContactName = $this->getClass('classContactName')) {
return $classContactName;
}
return 'col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left';
}
protected function getClassAmount($type, $classAmount)
{
if (!empty($classAmount)) {
return $classAmount;
}
if ($classAmount = $this->getClass('classAmount')) {
return $classAmount;
}
return 'col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right';
}
protected function getTextIssueAt($type, $textIssueAt)
{
if (!empty($textIssueAt)) {
return $textIssueAt;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textIssueAt = 'invoices.invoice_date';
break;
case 'bill':
case 'expense':
case 'purchase':
$textIssueAt = 'bills.bill_date';
break;
}
return $textIssueAt;
}
protected function getclassIssuedAt($type, $classIssuedAt)
{
if (!empty($classIssuedAt)) {
return $classIssuedAt;
}
if ($classIssuedAt = $this->getClass('classIssuedAt')) {
return $classIssuedAt;
}
return 'col-lg-2 col-xl-2 d-none d-lg-block text-left';
}
protected function getTextDueAt($type, $textDueAt)
{
if (!empty($textDueAt)) {
return $textDueAt;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDueAt = 'invoices.due_date';
break;
case 'bill':
case 'expense':
case 'purchase':
$textDueAt = 'bills.due_date';
break;
}
return $textDueAt;
}
protected function getClassDueAt($type, $classDueAt)
{
if (!empty($classDueAt)) {
return $classDueAt;
}
if ($classDueAt = $this->getClass('classDueAt')) {
return $classDueAt;
}
return 'col-lg-2 col-xl-2 d-none d-lg-block text-left';
}
protected function getTextDocumentStatus($type, $textDocumentStatus)
{
if (!empty($textDocumentStatus)) {
return $textDocumentStatus;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDocumentStatus = 'invoices.statuses.';
break;
case 'bill':
case 'expense':
case 'purchase':
$textDocumentStatus = 'bills.statuses.';
break;
}
return $textDocumentStatus;
}
protected function getClassStatus($type, $classStatus)
{
if (!empty($classStatus)) {
return $classStatus;
}
if ($classStatus = $this->getClass('classStatus')) {
return $classStatus;
}
return 'col-lg-1 col-xl-1 d-none d-lg-block text-center';
}
protected function getClassActions($type, $classActions)
{
if (!empty($classActions)) {
return $classActions;
}
if ($classActions = $this->getClass('classActions')) {
return $classActions;
}
return 'col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center';
}
protected function getRouteButtonShow($type, $routeButtonShow)
{
if (!empty($routeButtonShow)) {
return $routeButtonShow;
}
$page = Str::plural($type, 2);
$route = $page . '.show';
try {
//example route parameter.
$parameter = 1;
route($route, $parameter);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getRouteButtonEdit($type, $routeButtonEdit)
{
if (!empty($routeButtonEdit)) {
return $routeButtonEdit;
}
$page = Str::plural($type, 2);
$route = $page . '.edit';
try {
//example route parameter.
$parameter = 1;
route($route, $parameter);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getRouteButtonDuplicate($type, $routeButtonDuplicate)
{
if (!empty($routeButtonDuplicate)) {
return $routeButtonDuplicate;
}
$page = Str::plural($type, 2);
$route = $page . '.duplicate';
try {
//example route parameter.
$parameter = 1;
route($route, $parameter);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getRouteButtonCancelled($type, $routeButtonCancelled)
{
if (!empty($routeButtonCancelled)) {
return $routeButtonCancelled;
}
$page = Str::plural($type, 2);
$route = $page . '.cancelled';
try {
//example route parameter.
$parameter = 1;
route($route, $parameter);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getRouteButtonDelete($type, $routeButtonDelete)
{
if (!empty($routeButtonDelete)) {
return $routeButtonDelete;
}
$page = Str::plural($type, 2);
$route = $page . '.destroy';
try {
//example route parameter.
$parameter = 1;
route($route, $parameter);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
protected function getPermissionDocumentCreate($type, $permissionDocumentCreate)
{
if (!empty($permissionDocumentCreate)) {
return $permissionDocumentCreate;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$permissionDocumentCreate = 'create-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$permissionDocumentCreate = 'create-purchases-bills';
break;
}
return $permissionDocumentCreate;
}
protected function getPermissionDocumentUpdate($type, $permissionDocumentUpdate)
{
if (!empty($permissionDocumentUpdate)) {
return $permissionDocumentUpdate;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$permissionDocumentUpdate = 'update-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$permissionDocumentUpdate = 'update-purchases-bills';
break;
}
return $permissionDocumentUpdate;
}
protected function getPermissionDocumentDelete($type, $permissionDocumentDelete)
{
if (!empty($permissionDocumentDelete)) {
return $permissionDocumentDelete;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$permissionDocumentDelete = 'delete-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$permissionDocumentDelete = 'delete-purchases-bills';
break;
}
return $permissionDocumentDelete;
}
protected function calculateClass()
{
$hides = [
'BulkAction' => '1',
'DocumentNumber' => '1',
'ContactName' => '2',
'Amount' => '2',
'IssuedAt' => '2',
'DueAt' => '2',
'Status' => '1',
'Actions' => '1',
];
foreach ($hides as $hide => $count) {
if ($this->{'hide'. $hide}) {
$this->class_count -= $count;
}
}
}
protected function getClass($type)
{
$hide_count = 12 - $this->class_count;
if (empty($hide_count)) {
//return false;
}
$class = false;
switch($type) {
case 'classDocumentNumber':
switch ($hide_count) {
case 1:
$class = 'col-md-3 col-lg-2 col-xl-2 d-none d-md-block';
$this->class_count++;
break;
case 2:
$class = 'col-md-4 col-lg-2 col-xl-2 d-none d-md-block';
$this->class_count += 2;
break;
case 3:
$class = 'col-md-5 col-lg-2 col-xl-2 d-none d-md-block';
$this->class_count += 3;
break;
}
}
return $class;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,597 @@
<?php
namespace App\Abstracts\View\Components;
use Illuminate\View\Component;
use Illuminate\Support\Str;
use App\Traits\DateTime;
use App\Models\Common\Media;
use File;
use Image;
use Storage;
abstract class DocumentTemplate extends Component
{
use DateTime;
public $type;
public $document;
/** @var string */
public $documentTemplate;
public $date_format;
public $logo;
public $backGroundColor;
public $hideFooter;
public $hideCompanyLogo;
public $hideCompanyDetails;
public $hideCompanyName;
public $hideCompanyAddress;
public $hideCompanyTaxNumber;
public $hideCompanyPhone;
public $hideCompanyEmail;
public $hideContactInfo;
public $hideContactName;
public $hideContactAddress;
public $hideContactTaxNumber;
public $hideContactPhone;
public $hideContactEmail;
public $hideOrderNumber;
public $hideDocumentNumber;
public $hideIssuedAt;
public $hideDueAt;
public $textContactInfo;
/** @var string */
public $textIssuedAt;
/** @var string */
public $textDueAt;
/** @var string */
public $textDocumentNumber;
/** @var string */
public $textOrderNumber;
public $hideItems;
public $hideName;
public $hideDescription;
public $hideQuantity;
public $hidePrice;
public $hideDiscount;
public $hideAmount;
/** @var string */
public $textItems;
/** @var string */
public $textQuantity;
/** @var string */
public $textPrice;
/** @var string */
public $textAmount;
public $hideNote;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$type, $document, $documentTemplate = '', $logo = '', $backgroundColor = '',
bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false,
bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false,
bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false,
bool $hideOrderNumber = false, bool $hideDocumentNumber = false, bool $hideIssuedAt = false, bool $hideDueAt = false,
string $textContactInfo = '', string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '',
bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false, bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false, bool $hideNote = false,
string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = ''
) {
$this->type = $type;
$this->document = $document;
$this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate);
$this->logo = $this->getLogo($logo);
$this->backGroundColor = $this->getBackgroundColor($type, $backgroundColor);
$this->hideFooter = $hideFooter;
$this->hideCompanyLogo = $hideCompanyLogo;
$this->hideCompanyDetails = $hideCompanyDetails;
$this->hideCompanyName = $hideCompanyName;
$this->hideCompanyAddress = $hideCompanyAddress;
$this->hideCompanyTaxNumber = $hideCompanyTaxNumber;
$this->hideCompanyPhone = $hideCompanyPhone;
$this->hideCompanyEmail = $hideCompanyEmail;
$this->hideContactInfo = $hideContactInfo;
$this->hideContactName = $hideContactName;
$this->hideContactAddress = $hideContactAddress;
$this->hideContactTaxNumber = $hideContactTaxNumber;
$this->hideContactPhone = $hideContactPhone;
$this->hideContactEmail = $hideContactEmail;
$this->hideOrderNumber = $hideOrderNumber;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->hideIssuedAt = $hideIssuedAt;
$this->hideDueAt = $hideDueAt;
$this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo);
$this->textIssuedAt = $this->gettextIssuedAt($type, $textIssuedAt);
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
$this->textOrderNumber = $this->getTextOrderNumber($type, $textOrderNumber);
$this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription);
$this->hideName = $this->getHideName($type, $hideName);
$this->hideDescription = $this->getHideDescription($type, $hideDescription);
$this->hideQuantity = $this->getHideQuantity($type, $hideQuantity);
$this->hidePrice = $this->getHidePrice($type, $hidePrice);
$this->hideDiscount = $this->getHideDiscount($type, $hideDiscount);
$this->hideAmount = $this->getHideAmount($type, $hideAmount);
$this->hideNote = $hideNote;
$this->textItems = $this->getTextItems($type, $textItems);
$this->textQuantity = $this->getTextQuantity($type, $textQuantity);
$this->textPrice = $this->getTextPrice($type, $textPrice);
$this->textAmount = $this->getTextAmount($type, $textAmount);
}
protected function getDocumentTemplate($type, $documentTemplate)
{
if (!empty($documentTemplate)) {
return $documentTemplate;
}
// $documentTemplate = 'components.documents.template.default';
$documentTemplate = 'default';
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
// $documentTemplate = 'components.documents.template.' . setting('invoice.template', 'default');
$documentTemplate = setting('invoice.template', 'default');
break;
}
return $documentTemplate;
}
protected function getLogo($logo)
{
if (!empty($logo)) {
return $logo;
}
$media = Media::find(setting('company.logo'));
if (!empty($media)) {
$path = Storage::path($media->getDiskPath());
if (!is_file($path)) {
return $logo;
}
} else {
$path = base_path('public/img/company.png');
}
$image = Image::cache(function($image) use ($path) {
$width = $height = setting('invoice.logo_size', 128);
$image->make($path)->resize($width, $height)->encode();
});
if (empty($image)) {
return $logo;
}
$extension = File::extension($path);
return 'data:image/' . $extension . ';base64,' . base64_encode($image);
}
protected function getBackgroundColor($type, $backgroundColor)
{
if (!empty($backgroundColor)) {
return $backgroundColor;
}
$backgroundColor = '#55588b';
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$backgroundColor = setting('invoice.color');
break;
case 'bill':
case 'expense':
case 'purchase':
$backgroundColor = setting('bill.color');
break;
}
return $backgroundColor;
}
protected function getTextDocumentNumber($type, $textDocumentNumber)
{
if (!empty($textDocumentNumber)) {
return $textDocumentNumber;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDocumentNumber = 'invoices.invoice_number';
break;
case 'bill':
case 'expense':
case 'purchase':
$textDocumentNumber = 'bills.bill_number';
break;
}
return $textDocumentNumber;
}
protected function getTextOrderNumber($type, $textOrderNumber)
{
if (!empty($textOrderNumber)) {
return $textOrderNumber;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textOrderNumber = 'invoices.order_number';
break;
case 'bill':
case 'expense':
case 'purchase':
$textOrderNumber = 'bills.order_number';
break;
}
return $textOrderNumber;
}
protected function getTextContactInfo($type, $textContactInfo)
{
if (!empty($textContactInfo)) {
return $textContactInfo;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textContactInfo = 'invoices.bill_to';
break;
case 'bill':
case 'expense':
case 'purchase':
$textContactInfo = 'bills.bill_from';
break;
}
return $textContactInfo;
}
protected function gettextIssuedAt($type, $textIssuedAt)
{
if (!empty($textIssuedAt)) {
return $textIssuedAt;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textIssuedAt = 'invoices.invoice_date';
break;
case 'bill':
case 'expense':
case 'purchase':
$textIssuedAt = 'bills.bill_date';
break;
}
return $textIssuedAt;
}
protected function getTextDueAt($type, $textDueAt)
{
if (!empty($textDueAt)) {
return $textDueAt;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDueAt = 'invoices.due_date';
break;
case 'bill':
case 'expense':
case 'purchase':
$textDueAt = 'bills.due_date';
break;
}
return $textDueAt;
}
protected function getTextItems($type, $textItems)
{
if (!empty($textItems)) {
return $textItems;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textItems = setting('invoice.item_name', 'general.items');
if ($textItems == 'custom') {
$textItems = setting('invoice.item_name_input');
}
break;
case 'bill':
case 'expense':
case 'purchase':
$textItems = 'general.items';
break;
}
return $textItems;
}
protected function getTextQuantity($type, $textQuantity)
{
if (!empty($textQuantity)) {
return $textQuantity;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textQuantity = setting('invoice.quantity_name', 'invoices.quantity');
if ($textQuantity == 'custom') {
$textQuantity = setting('invoice.quantity_name_input');
}
break;
case 'bill':
case 'expense':
case 'purchase':
$textQuantity = 'bills.quantity';
break;
}
return $textQuantity;
}
protected function getTextPrice($type, $text_price)
{
if (!empty($text_price)) {
return $text_price;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$text_price = setting('invoice.price_name', 'invoices.price');
if ($text_price == 'custom') {
$text_price = setting('invoice.price_name_input');
}
break;
case 'bill':
case 'expense':
case 'purchase':
$text_price = 'bills.price';
break;
}
return $text_price;
}
protected function getTextAmount($type, $textAmount)
{
if (!empty($textAmount)) {
return $textAmount;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
case 'bill':
case 'expense':
case 'purchase':
$textAmount = 'general.amount';
break;
}
return $textAmount;
}
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
{
if (!empty($hideItems)) {
return $hideItems;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
return $hideItems;
}
protected function getHideName($type, $hideName)
{
if (!empty($hideName)) {
return $hideName;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideName = setting('invoice.hide_item_name', $hideName);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
}
return $hideName;
}
protected function getHideDescription($type, $hideDescription)
{
if (!empty($hideDescription)) {
return $hideDescription;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
}
return $hideDescription;
}
protected function getHideQuantity($type, $hideQuantity)
{
if (!empty($hideQuantity)) {
return $hideQuantity;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
}
return $hideQuantity;
}
protected function getHidePrice($type, $hidePrice)
{
if (!empty($hidePrice)) {
return $hidePrice;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
case 'bill':
case 'expense':
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
}
return $hidePrice;
}
protected function getHideDiscount($type, $hideDiscount)
{
if (!empty($hideDiscount)) {
return $hideDiscount;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
}
return $hideDiscount;
}
protected function getHideAmount($type, $hideAmount)
{
if (!empty($hideAmount)) {
return $hideAmount;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
}
return $hideAmount;
}
}

View File

@ -35,7 +35,7 @@ class Companies extends BulkAction
foreach ($companies as $company) {
try {
$this->dispatch(new UpdateCompany($company, $request->merge(['enabled' => 1])));
$this->dispatch(new UpdateCompany($company, $request->merge(['enabled' => 1]), session('company_id')));
} catch (\Exception $e) {
flash($e->getMessage())->error();
}
@ -48,7 +48,7 @@ class Companies extends BulkAction
foreach ($companies as $company) {
try {
$this->dispatch(new UpdateCompany($company, $request->merge(['enabled' => 0])));
$this->dispatch(new UpdateCompany($company, $request->merge(['enabled' => 0]), session('company_id')));
} catch (\Exception $e) {
flash($e->getMessage())->error();
}
@ -61,7 +61,7 @@ class Companies extends BulkAction
foreach ($companies as $company) {
try {
$this->dispatch(new DeleteCompany($company));
$this->dispatch(new DeleteCompany($company, session('company_id')));
} catch (\Exception $e) {
flash($e->getMessage())->error();
}

View File

@ -3,17 +3,17 @@
namespace App\BulkActions\Purchases;
use App\Abstracts\BulkAction;
use App\Events\Purchase\BillCancelled;
use App\Events\Purchase\BillReceived;
use App\Events\Document\DocumentCancelled;
use App\Events\Document\DocumentReceived;
use App\Exports\Purchases\Bills as Export;
use App\Jobs\Banking\CreateDocumentTransaction;
use App\Jobs\Purchase\CreateBillHistory;
use App\Jobs\Purchase\DeleteBill;
use App\Models\Purchase\Bill;
use App\Jobs\Banking\CreateBankingDocumentTransaction;
use App\Jobs\Document\CreateDocumentHistory;
use App\Jobs\Document\DeleteDocument;
use App\Models\Document\Document;
class Bills extends BulkAction
{
public $model = Bill::class;
public $model = Document::class;
public $actions = [
'paid' => [
@ -48,7 +48,7 @@ class Bills extends BulkAction
$bills = $this->getSelectedRecords($request);
foreach ($bills as $bill) {
$this->dispatch(new CreateDocumentTransaction($bill, []));
$this->dispatch(new CreateBankingDocumentTransaction($bill, ['type' => 'expense']));
}
}
@ -57,7 +57,7 @@ class Bills extends BulkAction
$bills = $this->getSelectedRecords($request);
foreach ($bills as $bill) {
event(new BillReceived($bill));
event(new DocumentReceived($bill));
}
}
@ -66,7 +66,7 @@ class Bills extends BulkAction
$bills = $this->getSelectedRecords($request);
foreach ($bills as $bill) {
event(new BillCancelled($bill));
event(new DocumentCancelled($bill));
}
}
@ -77,9 +77,9 @@ class Bills extends BulkAction
foreach ($bills as $bill) {
$clone = $bill->duplicate();
$description = trans('messages.success.added', ['type' => $clone->bill_number]);
$description = trans('messages.success.added', ['type' => $clone->document_number]);
$this->dispatch(new CreateBillHistory($clone, 0, $description));
$this->dispatch(new CreateDocumentHistory($clone, 0, $description));
}
}
@ -89,7 +89,7 @@ class Bills extends BulkAction
foreach ($bills as $bill) {
try {
$this->dispatch(new DeleteBill($bill));
$this->dispatch(new DeleteDocument($bill));
} catch (\Exception $e) {
flash($e->getMessage())->error();
}

View File

@ -3,17 +3,17 @@
namespace App\BulkActions\Sales;
use App\Abstracts\BulkAction;
use App\Events\Sale\InvoiceCancelled;
use App\Events\Sale\InvoiceCreated;
use App\Events\Sale\InvoiceSent;
use App\Events\Sale\PaymentReceived;
use App\Events\Document\DocumentCancelled;
use App\Events\Document\DocumentCreated;
use App\Events\Document\DocumentSent;
use App\Events\Document\PaymentReceived;
use App\Exports\Sales\Invoices as Export;
use App\Jobs\Sale\DeleteInvoice;
use App\Models\Sale\Invoice;
use App\Jobs\Document\DeleteDocument;
use App\Models\Document\Document;
class Invoices extends BulkAction
{
public $model = Invoice::class;
public $model = Document::class;
public $actions = [
'paid' => [
@ -48,7 +48,7 @@ class Invoices extends BulkAction
$invoices = $this->getSelectedRecords($request);
foreach ($invoices as $invoice) {
event(new PaymentReceived($invoice));
event(new PaymentReceived($invoice, ['type' => 'income']));
}
}
@ -57,7 +57,7 @@ class Invoices extends BulkAction
$invoices = $this->getSelectedRecords($request);
foreach ($invoices as $invoice) {
event(new InvoiceSent($invoice));
event(new DocumentSent($invoice));
}
}
@ -66,7 +66,7 @@ class Invoices extends BulkAction
$invoices = $this->getSelectedRecords($request);
foreach ($invoices as $invoice) {
event(new InvoiceCancelled($invoice));
event(new DocumentCancelled($invoice));
}
}
@ -77,7 +77,7 @@ class Invoices extends BulkAction
foreach ($invoices as $invoice) {
$clone = $invoice->duplicate();
event(new InvoiceCreated($clone));
event(new DocumentCreated($clone));
}
}
@ -92,7 +92,7 @@ class Invoices extends BulkAction
foreach ($invoices as $invoice) {
try {
$this->dispatch(new DeleteInvoice($invoice));
$this->dispatch(new DeleteDocument($invoice));
} catch (\Exception $e) {
flash($e->getMessage())->error();
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class BulkAction implements Classifier
{
public function name(): string
{
return 'Bulk Actions';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\BulkAction::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

29
app/Classifiers/Event.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Event implements Classifier
{
public function name(): string
{
return 'Events';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Event::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Export implements Classifier
{
public function name(): string
{
return 'Exports';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Export::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Import implements Classifier
{
public function name(): string
{
return 'Imports';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Import::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

29
app/Classifiers/Job.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Job implements Classifier
{
public function name(): string
{
return 'Jobs';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Job::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Observer implements Classifier
{
public function name(): string
{
return 'Observers';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Observer::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Report implements Classifier
{
public function name(): string
{
return 'Reports';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Report::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

29
app/Classifiers/Scope.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Scope implements Classifier
{
public function name(): string
{
return 'Scopes';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\Illuminate\Database\Eloquent\Scope::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Transformer implements Classifier
{
public function name(): string
{
return 'Transformers';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\League\Fractal\TransformerAbstract::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Classifiers;
use Wnx\LaravelStats\ReflectionClass;
use Wnx\LaravelStats\Contracts\Classifier;
class Widget implements Classifier
{
public function name(): string
{
return 'Widgets';
}
public function satisfies(ReflectionClass $class): bool
{
return $class->isSubclassOf(\App\Abstracts\Widget::class);
}
public function countsTowardsApplicationCode(): bool
{
return true;
}
public function countsTowardsTests(): bool
{
return false;
}
}

View File

@ -2,9 +2,10 @@
namespace App\Console\Commands;
use App\Events\Purchase\BillReminded;
use App\Events\Document\DocumentReminded;
use App\Models\Common\Company;
use App\Models\Purchase\Bill;
use App\Models\Document\Document;
use App\Notifications\Purchase\Bill as Notification;
use App\Utilities\Overrider;
use Date;
use Illuminate\Console\Command;
@ -80,11 +81,11 @@ class BillReminder extends Command
$date = Date::today()->addDays($day)->toDateString();
// Get upcoming bills
$bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor();
$bills = Document::bill()->with('contact')->accrued()->notPaid()->due($date)->cursor();
foreach ($bills as $bill) {
try {
event(new BillReminded($bill));
event(new DocumentReminded($bill, Notification::class));
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
$this->error($e->getMessage());

View File

@ -0,0 +1,131 @@
<?php
namespace App\Console\Commands;
use App\Jobs\Install\CopyFiles;
use App\Jobs\Install\DownloadFile;
use App\Jobs\Install\UnzipFile;
use App\Traits\Jobs;
use App\Utilities\Versions;
use Illuminate\Console\Command;
class DownloadModule extends Command
{
use Jobs;
const CMD_SUCCESS = 0;
const CMD_ERROR = 1;
public $alias;
public $company;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'module:download {alias} {company}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Download the specified module.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
set_time_limit(3600); // 1 hour
$this->alias = $this->argument('alias');
$this->company = $this->argument('company');
session(['company_id' => $this->company]);
setting()->setExtraColumns(['company_id' => $this->company]);
if (!$path = $this->download()) {
return self::CMD_ERROR;
}
if (!$this->unzip($path)) {
return self::CMD_ERROR;
}
if (!$this->copyFiles($path)) {
return self::CMD_ERROR;
}
$this->info("Module [{$this->alias}] downloaded!");
return self::CMD_SUCCESS;
}
public function download()
{
$this->info('Downloading module...');
try {
$path = $this->dispatch(new DownloadFile($this->alias, $this->getVersion()));
} catch (\Exception $e) {
$this->error($e->getMessage());
return false;
}
return $path;
}
public function unzip($path)
{
$this->info('Unzipping module...');
try {
$this->dispatch(new UnzipFile($this->alias, $path));
} catch (\Exception $e) {
$this->error($e->getMessage());
return false;
}
return true;
}
public function copyFiles($path)
{
$this->info('Copying module files...');
try {
$this->dispatch(new CopyFiles($this->alias, $path));
event(new \App\Events\Module\Copied($this->alias, $this->company));
} catch (\Exception $e) {
$this->error($e->getMessage());
return false;
}
return true;
}
protected function getVersion()
{
$version = Versions::latest($this->alias);
if (empty($version)) {
$current = '1.0.0';
$url = 'apps/' . $this->alias . '/version/' . $current . '/' . version('short');
$version = Versions::getLatestVersion($url, $current);
}
return $version;
}
}

View File

@ -2,9 +2,10 @@
namespace App\Console\Commands;
use App\Events\Sale\InvoiceReminded;
use App\Events\Document\DocumentReminded;
use App\Models\Common\Company;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Notifications\Sale\Invoice as Notification;
use App\Utilities\Overrider;
use Date;
use Illuminate\Console\Command;
@ -80,11 +81,11 @@ class InvoiceReminder extends Command
$date = Date::today()->subDays($day)->toDateString();
// Get upcoming invoices
$invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor();
$invoices = Document::invoice()->with('contact')->accrued()->notPaid()->due($date)->cursor();
foreach ($invoices as $invoice) {
try {
event(new InvoiceReminded($invoice));
event(new DocumentReminded($invoice, Notification::class));
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
$this->error($e->getMessage());

View File

@ -4,13 +4,11 @@ namespace App\Console\Commands;
use App\Events\Banking\TransactionCreated;
use App\Events\Banking\TransactionRecurring;
use App\Events\Purchase\BillCreated;
use App\Events\Purchase\BillRecurring;
use App\Events\Sale\InvoiceCreated;
use App\Events\Sale\InvoiceRecurring;
use App\Events\Document\DocumentCreated;
use App\Events\Document\DocumentRecurring;
use App\Models\Banking\Transaction;
use App\Models\Common\Recurring;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Utilities\Date;
use App\Utilities\Overrider;
use Illuminate\Console\Command;
@ -136,16 +134,10 @@ class RecurringCheck extends Command
}
switch ($type) {
case 'App\Models\Purchase\Bill':
event(new BillCreated($clone));
case 'App\Models\Document\Document':
event(new DocumentCreated($clone));
event(new BillRecurring($clone));
break;
case 'App\Models\Sale\Invoice':
event(new InvoiceCreated($clone));
event(new InvoiceRecurring($clone));
event(new DocumentRecurring($clone));
break;
case 'App\Models\Banking\Transaction':
@ -272,11 +264,9 @@ class RecurringCheck extends Command
return 'paid_at';
}
if ($model instanceof Invoice) {
return 'invoiced_at';
if ($model instanceof Document) {
return 'issued_at';
}
return 'billed_at';
}
protected function getTable($model)
@ -285,10 +275,8 @@ class RecurringCheck extends Command
return 'transactions';
}
if ($model instanceof Invoice) {
return 'invoices';
if ($model instanceof Document) {
return 'documents';
}
return 'bills';
}
}

View File

@ -2,18 +2,29 @@
namespace App\Console\Commands;
use App\Utilities\Updater;
use App\Events\Install\UpdateCopied;
use App\Events\Install\UpdateDownloaded;
use App\Events\Install\UpdateUnzipped;
use App\Jobs\Install\CopyFiles;
use App\Jobs\Install\DownloadFile;
use App\Jobs\Install\FinishUpdate;
use App\Jobs\Install\UnzipFile;
use App\Traits\Jobs;
use App\Utilities\Versions;
use Illuminate\Console\Command;
class Update extends Command
{
use Jobs;
const CMD_SUCCESS = 0;
const CMD_ERROR = 1;
public $alias;
public $company;
public $new;
public $old;
@ -42,6 +53,7 @@ class Update extends Command
set_time_limit(3600); // 1 hour
$this->alias = $this->argument('alias');
$this->company = $this->argument('company');
if (false === $this->new = $this->getNewVersion()) {
$this->error('Not able to get the latest version of ' . $this->alias . '!');
@ -51,8 +63,8 @@ class Update extends Command
$this->old = $this->getOldVersion();
session(['company_id' => $this->argument('company')]);
setting()->setExtraColumns(['company_id' => $this->argument('company')]);
session(['company_id' => $this->company]);
setting()->setExtraColumns(['company_id' => $this->company]);
if (!$path = $this->download()) {
return self::CMD_ERROR;
@ -96,7 +108,9 @@ class Update extends Command
$this->info('Downloading update...');
try {
$path = Updater::download($this->alias, $this->new, $this->old);
$path = $this->dispatch(new DownloadFile($this->alias, $this->new));
event(new UpdateDownloaded($this->alias, $this->new, $this->old));
} catch (\Exception $e) {
$this->error($e->getMessage());
@ -111,7 +125,9 @@ class Update extends Command
$this->info('Unzipping update...');
try {
Updater::unzip($path, $this->alias, $this->new, $this->old);
$this->dispatch(new UnzipFile($this->alias, $path));
event(new UpdateUnzipped($this->alias, $this->new, $this->old));
} catch (\Exception $e) {
$this->error($e->getMessage());
@ -126,7 +142,9 @@ class Update extends Command
$this->info('Copying update files...');
try {
Updater::copyFiles($path, $this->alias, $this->new, $this->old);
$this->dispatch(new CopyFiles($this->alias, $path));
event(new UpdateCopied($this->alias, $this->new, $this->old));
} catch (\Exception $e) {
$this->error($e->getMessage());
@ -141,7 +159,7 @@ class Update extends Command
$this->info('Finishing update...');
try {
Updater::finish($this->alias, $this->new, $this->old);
$this->dispatch(new FinishUpdate($this->alias, $this->new, $this->old, $this->company));
} catch (\Exception $e) {
$this->error($e->getMessage());

View File

@ -9,11 +9,11 @@ use Symfony\Component\Console\Input\InputArgument;
class $CLASS$ extends Command
{
/**
* The console command name.
* The name and signature of the console command.
*
* @var string
*/
protected $name = '$COMMAND_NAME$';
protected $signature = '$COMMAND_NAME$';
/**
* The console command description.

View File

@ -0,0 +1,28 @@
<?php
namespace $NAMESPACE$;
use Illuminate\View\Component;
class $CLASS$ extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('$ALIAS$::$VIEW_NAME$');
}
}

View File

@ -3,7 +3,6 @@
namespace $CLASS_NAMESPACE$;
use App\Abstracts\Http\Controller;
use App\Abstracts\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@ -11,15 +10,17 @@ class $CLASS$ extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return view('$ALIAS$::index');
return $this->response('$ALIAS$::index');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
@ -29,6 +30,7 @@ class $CLASS$ extends Controller
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
@ -39,6 +41,7 @@ class $CLASS$ extends Controller
/**
* Show the specified resource.
*
* @param int $id
* @return Response
*/
@ -49,6 +52,7 @@ class $CLASS$ extends Controller
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
@ -59,6 +63,7 @@ class $CLASS$ extends Controller
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
@ -70,6 +75,7 @@ class $CLASS$ extends Controller
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/

View File

@ -2,12 +2,10 @@
namespace $NAMESPACE$;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class $CLASS$
class $CLASS$ extends Event
{
use SerializesModels;
/**
* Create a new event instance.
*

View File

@ -1,9 +1,28 @@
<?php
use Faker\Generator as Faker;
namespace $NAMESPACE$;
$factory->define(Model::class, function (Faker $faker) {
return [
//
];
});
use Illuminate\Database\Eloquent\Factories\Factory;
use Faker\Generator as Faker;
class $NAME$ extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \$MODEL_NAMESPACE$\$NAME$::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
//
];
}
}

View File

@ -12,5 +12,6 @@
"requires": [],
"reports": [],
"widgets": [],
"settings": []
"settings": [],
"extra-modules": {}
}

View File

@ -3,8 +3,21 @@
namespace $NAMESPACE$;
use App\Abstracts\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class $CLASS$ extends Model
{
use HasFactory;
protected $fillable = $FILLABLE$;
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \$FACTORY_NAMESPACE$\$NAME$::new();
}
}

View File

@ -2,6 +2,7 @@
namespace $NAMESPACE$;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider as Provider;
class $NAME$ extends Provider
@ -14,9 +15,9 @@ class $NAME$ extends Provider
public function boot()
{
$this->loadViews();
$this->loadViewComponents();
$this->loadTranslations();
$this->loadMigrations();
$this->loadFactories();
//$this->loadConfig();
}
@ -40,6 +41,16 @@ class $NAME$ extends Provider
$this->loadViewsFrom(__DIR__ . '/../Resources/views', '$ALIAS$');
}
/**
* Load view components.
*
* @return void
*/
public function loadViewComponents()
{
Blade::componentNamespace('$COMPONENT_NAMESPACE$', '$ALIAS$');
}
/**
* Load translations.
*
@ -60,20 +71,6 @@ class $NAME$ extends Provider
$this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
}
/**
* Load factories.
*
* @return void
*/
public function loadFactories()
{
if (app()->environment('production') || !app()->runningInConsole()) {
return;
}
$this->loadFactoriesFrom(__DIR__ . '/../$FACTORIES_PATH$');
}
/**
* Load config.
*

View File

@ -0,0 +1,28 @@
<?php
namespace App\Events\Auth;
use App\Abstracts\Event;
class ApiPermissionsAssigning extends Event
{
public $permission;
public $table;
public $type;
/**
* Create a new event instance.
*
* @param $permission
* @param $table
* @param $type
*/
public function __construct($permission, $table, $type)
{
$this->permission = $permission;
$this->table = $table;
$this->type = $type;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Events\Auth;
use App\Abstracts\Event;
class Attempting extends Event
{
public $alias;
public $company_id;
public $protocol;
/**
* Create a new event instance.
*
* @param $alias
* @param $company_id
* @param $protocol
*/
public function __construct($alias, $company_id = null, $protocol = 'basic')
{
$this->alias = $alias;
$this->company_id = $company_id;
$this->protocol = $protocol;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Events\Auth;
use App\Abstracts\Event;
class Authenticated extends Event
{
public $alias;
public $company_id;
public $protocol;
/**
* Create a new event instance.
*
* @param $alias
* @param $company_id
* @param $protocol
*/
public function __construct($alias, $company_id = null, $protocol = 'basic')
{
$this->alias = $alias;
$this->company_id = $company_id;
$this->protocol = $protocol;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Events\Auth;
use App\Abstracts\Event;
class Failed extends Event
{
public $alias;
public $company_id;
public $protocol;
/**
* Create a new event instance.
*
* @param $alias
* @param $company_id
* @param $protocol
*/
public function __construct($alias, $company_id = null, $protocol = 'basic')
{
$this->alias = $alias;
$this->company_id = $company_id;
$this->protocol = $protocol;
}
}

View File

@ -2,12 +2,10 @@
namespace App\Events\Auth;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class LandingPageShowing
class LandingPageShowing extends Event
{
use SerializesModels;
public $user;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Banking;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class TransactionCreated
class TransactionCreated extends Event
{
use SerializesModels;
public $transaction;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Banking;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class TransactionCreating
class TransactionCreating extends Event
{
use SerializesModels;
public $request;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Banking;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class TransactionRecurring
class TransactionRecurring extends Event
{
use SerializesModels;
public $transaction;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class BulkActionsAdding
class BulkActionsAdding extends Event
{
use SerializesModels;
public $bulk_action;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class CompanyCreated
class CompanyCreated extends Event
{
use SerializesModels;
public $company;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class CompanyCreating
class CompanyCreating extends Event
{
use SerializesModels;
public $request;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class CompanySwitched
class CompanySwitched extends Event
{
use SerializesModels;
public $company;
public $old_company_id;

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class CompanyUpdated
class CompanyUpdated extends Event
{
use SerializesModels;
public $company;
public $request;

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class CompanyUpdating
class CompanyUpdating extends Event
{
use SerializesModels;
public $company;
public $request;

View File

@ -2,12 +2,10 @@
namespace App\Events\Common;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class GlobalSearched
class GlobalSearched extends Event
{
use SerializesModels;
public $search;
/**

View File

@ -0,0 +1,22 @@
<?php
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
class DocumentCancelled
{
use SerializesModels;
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class DocumentCreated extends Event
{
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -1,10 +1,10 @@
<?php
namespace App\Events\Sale;
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
class InvoiceCreating
class DocumentCreating
{
use SerializesModels;

View File

@ -0,0 +1,22 @@
<?php
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
class DocumentPrinting
{
use SerializesModels;
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
class DocumentReceived
{
use SerializesModels;
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
class DocumentRecurring
{
use SerializesModels;
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
use App\Models\Document\Document;
class DocumentReminded extends Event
{
public $document;
public $notification;
/**
* Create a new event instance.
*
* @param $document
* @param $notification
*/
public function __construct(Document $document, string $notification)
{
$this->document = $document;
$this->notification = $notification;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class DocumentSent extends Event
{
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class DocumentUpdated extends Event
{
public $document;
public $request;
/**
* Create a new event instance.
*
* @param $document
* @param $request
*/
public function __construct($document, $request)
{
$this->document = $document;
$this->request = $request;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class DocumentUpdating extends Event
{
public $document;
public $request;
/**
* Create a new event instance.
*
* @param $document
* @param $request
*/
public function __construct($document, $request)
{
$this->document = $document;
$this->request = $request;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class DocumentViewed extends Event
{
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -2,12 +2,10 @@
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class PaidAmountCalculated
class PaidAmountCalculated extends Event
{
use SerializesModels;
public $model;
/**

View File

@ -0,0 +1,23 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class PaymentReceived extends Event
{
public $document;
public $request;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document, $request = [])
{
$this->document = $document;
$this->request = $request;
}
}

View File

@ -2,12 +2,10 @@
namespace App\Events\Document;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class TransactionsCounted
class TransactionsCounted extends Event
{
use SerializesModels;
public $model;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Install;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class UpdateCacheCleared
class UpdateCacheCleared extends Event
{
use SerializesModels;
public $company_id;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Install;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class UpdateCopied
class UpdateCopied extends Event
{
use SerializesModels;
public $alias;
public $old;

View File

@ -2,12 +2,10 @@
namespace App\Events\Install;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class UpdateDownloaded
class UpdateDownloaded extends Event
{
use SerializesModels;
public $alias;
public $old;

View File

@ -2,12 +2,10 @@
namespace App\Events\Install;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class UpdateFinished
class UpdateFinished extends Event
{
use SerializesModels;
public $alias;
public $new;

View File

@ -2,12 +2,10 @@
namespace App\Events\Install;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class UpdateUnzipped
class UpdateUnzipped extends Event
{
use SerializesModels;
public $alias;
public $old;

View File

@ -2,12 +2,10 @@
namespace App\Events\Menu;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class AdminCreated
class AdminCreated extends Event
{
use SerializesModels;
public $menu;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Menu;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class PortalCreated
class PortalCreated extends Event
{
use SerializesModels;
public $menu;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class Copied
class Copied extends Event
{
use SerializesModels;
public $alias;
public $company_id;

View File

@ -2,12 +2,10 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class Disabled
class Disabled extends Event
{
use SerializesModels;
public $alias;
public $company_id;

View File

@ -2,12 +2,10 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class Enabled
class Enabled extends Event
{
use SerializesModels;
public $alias;
public $company_id;

View File

@ -2,25 +2,27 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class Installed
class Installed extends Event
{
use SerializesModels;
public $alias;
public $company_id;
public $locale;
/**
* Create a new event instance.
*
* @param $alias
* @param $company_id
* @param $locale
*/
public function __construct($alias, $company_id)
public function __construct($alias, $company_id, $locale)
{
$this->alias = $alias;
$this->company_id = $company_id;
$this->locale = $locale;
}
}

View File

@ -2,12 +2,10 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class PaymentMethodShowing
class PaymentMethodShowing extends Event
{
use SerializesModels;
public $modules;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class SettingShowing
class SettingShowing extends Event
{
use SerializesModels;
public $modules;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Module;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class Uninstalled
class Uninstalled extends Event
{
use SerializesModels;
public $alias;
public $company_id;

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillCancelled
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillCreated
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillCreating
{
use SerializesModels;
public $request;
/**
* Create a new event instance.
*
* @param $request
*/
public function __construct($request)
{
$this->request = $request;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillReceived
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillRecurring
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillReminded
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillUpdated
{
use SerializesModels;
public $bill;
/**
* Create a new event instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace App\Events\Purchase;
use Illuminate\Queue\SerializesModels;
class BillUpdating
{
use SerializesModels;
public $bill;
public $request;
/**
* Create a new event instance.
*
* @param $bill
* @param $request
*/
public function __construct($bill, $request)
{
$this->bill = $bill;
$this->request = $request;
}
}

View File

@ -2,12 +2,10 @@
namespace App\Events\Report;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class DataLoaded
class DataLoaded extends Event
{
use SerializesModels;
public $class;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Report;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class DataLoading
class DataLoading extends Event
{
use SerializesModels;
public $class;
/**

View File

@ -2,12 +2,10 @@
namespace App\Events\Report;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class FilterApplying
class FilterApplying extends Event
{
use SerializesModels;
public $class;
public $model;

View File

@ -2,12 +2,10 @@
namespace App\Events\Report;
use Illuminate\Queue\SerializesModels;
use App\Abstracts\Event;
class FilterShowing
class FilterShowing extends Event
{
use SerializesModels;
public $class;
/**

Some files were not shown because too many files have changed in this diff Show More