master branch merge

This commit is contained in:
Cüneyt Şentürk 2020-05-29 14:04:34 +03:00
commit a13a826056
224 changed files with 3473 additions and 1549 deletions

View File

@ -123,8 +123,6 @@ abstract class BulkAction
foreach ($items as $item) { foreach ($items as $item) {
$item->delete(); $item->delete();
} }
Artisan::call('cache:clear');
} }
public function disableContacts($request) public function disableContacts($request)

View File

@ -3,6 +3,7 @@
namespace App\Abstracts; namespace App\Abstracts;
use App\Scopes\Company; use App\Scopes\Company;
use App\Traits\Tenants;
use GeneaLabs\LaravelModelCaching\Traits\Cachable; use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@ -11,7 +12,9 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
abstract class Model extends Eloquent abstract class Model extends Eloquent
{ {
use Cachable, SearchString, SoftDeletes, Sortable; use Cachable, SearchString, SoftDeletes, Sortable, Tenants;
protected $tenantable = true;
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];

View File

@ -329,7 +329,7 @@ abstract class Report
event(new RowsShowing($this)); event(new RowsShowing($this));
} }
public function setTotals($items, $date_field, $check_type = false, $table = 'default') public function setTotals($items, $date_field, $check_type = false, $table = 'default', $with_tax = true)
{ {
foreach ($items as $item) { foreach ($items as $item) {
// Make groups extensible // Make groups extensible
@ -347,7 +347,7 @@ abstract class Report
continue; continue;
} }
$amount = $item->getAmountConvertedToDefault(); $amount = $item->getAmountConvertedToDefault(false, $with_tax);
$type = (($item instanceof Invoice) || (($item instanceof Transaction) && ($item->type == 'income'))) ? 'income' : 'expense'; $type = (($item instanceof Invoice) || (($item instanceof Transaction) && ($item->type == 'income'))) ? 'income' : 'expense';

View File

@ -23,11 +23,11 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
// Not installed yet // Not installed yet
if (!env('APP_INSTALLED')) { if (!config('app.installed')) {
return; return;
} }
$schedule_time = env('APP_SCHEDULE_TIME', '09:00'); $schedule_time = config('app.schedule_time');
$schedule->command('reminder:invoice')->dailyAt($schedule_time); $schedule->command('reminder:invoice')->dailyAt($schedule_time);
$schedule->command('reminder:bill')->dailyAt($schedule_time); $schedule->command('reminder:bill')->dailyAt($schedule_time);

View File

@ -1,25 +1,16 @@
{ {
"name": "$VENDOR$/$LOWER_NAME$", "require": {
"description": "",
"authors": [
{
"name": "$AUTHOR_NAME$",
"email": "$AUTHOR_EMAIL$"
}
],
"autoload": {
"psr-4": {
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": ""
}
}, },
"extra": { "replace": {
"laravel": { "guzzlehttp/guzzle": "*",
"providers": [ "guzzlehttp/psr7": "*",
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\Main" "laravel/framework": "*",
], "symfony/http-foundation": "*"
"aliases": { },
"scripts": {
} "test": [
} "composer install --prefer-dist --no-interaction --no-scripts --no-suggest --no-progress --no-ansi"
]
} }
} }

View File

@ -5,7 +5,7 @@ namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners;
use App\Events\Module\Installed as Event; use App\Events\Module\Installed as Event;
use App\Traits\Permissions; use App\Traits\Permissions;
class InstallModule class FinishInstallation
{ {
use Permissions; use Permissions;

View File

@ -3,7 +3,7 @@
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers; namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider;
use $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners\InstallModule; use $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners\FinishInstallation;
class Event extends Provider class Event extends Provider
{ {
@ -14,7 +14,7 @@ class Event extends Provider
*/ */
protected $listen = [ protected $listen = [
\App\Events\Module\Installed::class => [ \App\Events\Module\Installed::class => [
InstallModule::class, FinishInstallation::class,
], ],
]; ];
} }

View File

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

View File

@ -54,7 +54,7 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Throwable $exception) public function render($request, Throwable $exception)
{ {
if (env('APP_DEBUG') === false) { if (config('app.debug') === false) {
return $this->handleExceptions($request, $exception); return $this->handleExceptions($request, $exception);
} }

View File

@ -9,7 +9,7 @@ class Payments extends Export
{ {
public function collection() public function collection()
{ {
$model = Model::with(['account', 'bill', 'category', 'contact'])->type('expense')->usingSearchString(request('search')); $model = Model::with(['account', 'bill', 'category', 'contact'])->expense()->usingSearchString(request('search'));
if (!empty($this->ids)) { if (!empty($this->ids)) {
$model->whereIn('id', (array) $this->ids); $model->whereIn('id', (array) $this->ids);

View File

@ -9,7 +9,7 @@ class BillTransactions extends Export
{ {
public function collection() public function collection()
{ {
$model = Model::with(['account', 'category', 'contact', 'bill'])->type('expense')->isDocument()->usingSearchString(request('search')); $model = Model::with(['account', 'category', 'contact', 'bill'])->expense()->isDocument()->usingSearchString(request('search'));
if (!empty($this->ids)) { if (!empty($this->ids)) {
$model->whereIn('document_id', (array) $this->ids); $model->whereIn('document_id', (array) $this->ids);

View File

@ -9,7 +9,7 @@ class Revenues extends Export
{ {
public function collection() public function collection()
{ {
$model = Model::with(['account', 'category', 'contact', 'invoice'])->type('income')->usingSearchString(request('search')); $model = Model::with(['account', 'category', 'contact', 'invoice'])->income()->usingSearchString(request('search'));
if (!empty($this->ids)) { if (!empty($this->ids)) {
$model->whereIn('id', (array) $this->ids); $model->whereIn('id', (array) $this->ids);

View File

@ -9,7 +9,7 @@ class InvoiceTransactions extends Export
{ {
public function collection() public function collection()
{ {
$model = Model::with(['account', 'category', 'contact', 'invoice'])->type('income')->isDocument()->usingSearchString(request('search')); $model = Model::with(['account', 'category', 'contact', 'invoice'])->income()->isDocument()->usingSearchString(request('search'));
if (!empty($this->ids)) { if (!empty($this->ids)) {
$model->whereIn('document_id', (array) $this->ids); $model->whereIn('document_id', (array) $this->ids);

View File

@ -115,7 +115,7 @@ class Login extends Controller
auth()->logout(); auth()->logout();
// Session destroy is required if stored in database // Session destroy is required if stored in database
if (env('SESSION_DRIVER') == 'database') { if (config('session.driver') == 'database') {
$request = app('Illuminate\Http\Request'); $request = app('Illuminate\Http\Request');
$request->session()->getHandler()->destroy($request->session()->getId()); $request->session()->getHandler()->destroy($request->session()->getId());
} }

View File

@ -11,6 +11,7 @@ use App\Jobs\Banking\UpdateReconciliation;
use App\Models\Banking\Account; use App\Models\Banking\Account;
use App\Models\Banking\Reconciliation; use App\Models\Banking\Reconciliation;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use Date;
class Reconciliations extends Controller class Reconciliations extends Controller
{ {
@ -48,8 +49,8 @@ class Reconciliations extends Controller
$accounts = Account::enabled()->pluck('name', 'id'); $accounts = Account::enabled()->pluck('name', 'id');
$account_id = request('account_id', setting('default.account')); $account_id = request('account_id', setting('default.account'));
$started_at = request('started_at', '0000-00-00'); $started_at = request('started_at', Date::now()->firstOfMonth()->toDateString());
$ended_at = request('ended_at', '0000-00-00'); $ended_at = request('ended_at', Date::now()->endOfMonth()->toDateString());
$account = Account::find($account_id); $account = Account::find($account_id);

View File

@ -47,38 +47,33 @@ class Dashboards extends Controller
* *
* @return Response * @return Response
*/ */
public function show(Dashboard $dashboard) public function show($dashboard_id = null)
{ {
$dashboard_id = session('dashboard_id', 0); $dashboard_id = $dashboard_id ?? session('dashboard_id');
if ($dashboard) { if (empty($dashboard_id)) {
$dashboard_id = $dashboard->id; $dashboard_id = user()->dashboards()->enabled()->pluck('id')->first();
} }
// Change Dashboard if (!empty($dashboard_id)) {
if (request()->get('dashboard_id', 0)) { $dashboard = Dashboard::find($dashboard_id);
$dashboard_id = request()->get('dashboard_id');
session(['dashboard_id' => $dashboard_id]);
} }
$dashboards = user()->dashboards()->enabled()->get(); if (empty($dashboard)) {
$dashboard = $this->dispatch(new CreateDashboard([
if (!$dashboard_id) { 'company_id' => session('company_id'),
$dashboard_id = $dashboards->pluck('id')->first(); 'name' => trans_choice('general.dashboards', 1),
'with_widgets' => true,
]));
} }
// Dashboard
$dashboard = Dashboard::find($dashboard_id);
// Widgets
$widgets = Widget::where('dashboard_id', $dashboard->id)->orderBy('sort', 'asc')->get()->filter(function ($widget) { $widgets = Widget::where('dashboard_id', $dashboard->id)->orderBy('sort', 'asc')->get()->filter(function ($widget) {
return Widgets::canRead($widget->class); return Widgets::canRead($widget->class);
}); });
$financial_start = $this->getFinancialStart()->format('Y-m-d'); $financial_start = $this->getFinancialStart()->format('Y-m-d');
return view('common.dashboards.show', compact('dashboards', 'dashboard', 'widgets', 'financial_start')); return view('common.dashboards.show', compact('dashboard', 'widgets', 'financial_start'));
} }
/** /**

View File

@ -50,7 +50,7 @@ class Items extends Controller
*/ */
public function create() public function create()
{ {
$categories = Category::type('item')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::item()->enabled()->orderBy('name')->pluck('name', 'id');
$taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');
@ -129,7 +129,7 @@ class Items extends Controller
*/ */
public function edit(Item $item) public function edit(Item $item)
{ {
$categories = Category::type('item')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::item()->enabled()->orderBy('name')->pluck('name', 'id');
$taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Common; namespace App\Http\Controllers\Common;
use App\Abstracts\Http\Controller; use App\Abstracts\Http\Controller;
use App\Events\Common\GlobalSearched;
use App\Models\Banking\Account; use App\Models\Banking\Account;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use App\Models\Common\Contact; use App\Models\Common\Contact;
@ -19,53 +20,53 @@ class Search extends Controller
*/ */
public function index() public function index()
{ {
$results = array(); $search = new \stdClass();
$search->results = [];
$search->keyword = request('keyword');
$keyword = request('keyword'); $accounts = Account::enabled()->usingSearchString($search->keyword)->get();
$accounts = Account::enabled()->usingSearchString($keyword)->get();
if ($accounts->count()) { if ($accounts->count()) {
foreach ($accounts as $account) { foreach ($accounts as $account) {
$results[] = (object)[ $search->results[] = (object) [
'id' => $account->id, 'id' => $account->id,
'name' => $account->name, 'name' => $account->name,
'type' => trans_choice('general.accounts', 1), 'type' => trans_choice('general.accounts', 1),
'color' => '#55588b', 'color' => '#55588b',
'href' => url('banking/accounts/' . $account->id . '/edit'), 'href' => route('accounts.edit', $account->id),
]; ];
} }
} }
$items = Item::enabled()->usingSearchString($keyword)->get(); $items = Item::enabled()->usingSearchString($search->keyword)->get();
if ($items->count()) { if ($items->count()) {
foreach ($items as $item) { foreach ($items as $item) {
$results[] = (object)[ $search->results[] = (object) [
'id' => $item->id, 'id' => $item->id,
'name' => $item->name, 'name' => $item->name,
'type' => trans_choice('general.items', 1), 'type' => trans_choice('general.items', 1),
'color' => '#efad32', 'color' => '#efad32',
'href' => url('common/items/' . $item->id . '/edit'), 'href' => route('items.edit', $item->id),
]; ];
} }
} }
$invoices = Invoice::usingSearchString($keyword)->get(); $invoices = Invoice::usingSearchString($search->keyword)->get();
if ($invoices->count()) { if ($invoices->count()) {
foreach ($invoices as $invoice) { foreach ($invoices as $invoice) {
$results[] = (object)[ $search->results[] = (object) [
'id' => $invoice->id, 'id' => $invoice->id,
'name' => $invoice->invoice_number . ' - ' . $invoice->contact_name, 'name' => $invoice->invoice_number . ' - ' . $invoice->contact_name,
'type' => trans_choice('general.invoices', 1), 'type' => trans_choice('general.invoices', 1),
'color' => '#6da252', 'color' => '#6da252',
'href' => url('sales/invoices/' . $invoice->id), 'href' => route('invoices.show', $invoice->id),
]; ];
} }
}/* }/*
$income_transactions = Transaction::type('income')->usingSearchString($keyword)->get(); $income_transactions = Transaction::income()->usingSearchString($keyword)->get();
if ($income_transactions->count()) { if ($income_transactions->count()) {
foreach ($income_transactions as $transaction) { foreach ($income_transactions as $transaction) {
@ -79,35 +80,35 @@ class Search extends Controller
} }
}*/ }*/
$customers = Contact::customer()->enabled()->usingSearchString($keyword)->get(); $customers = Contact::customer()->enabled()->usingSearchString($search->keyword)->get();
if ($customers->count()) { if ($customers->count()) {
foreach ($customers as $customer) { foreach ($customers as $customer) {
$results[] = (object)[ $search->results[] = (object) [
'id' => $customer->id, 'id' => $customer->id,
'name' => $customer->name, 'name' => $customer->name,
'type' => trans_choice('general.customers', 1), 'type' => trans_choice('general.customers', 1),
'color' => '#328aef', 'color' => '#328aef',
'href' => url('sales/customers/' . $customer->id), 'href' => route('customers.show', $customer->id),
]; ];
} }
} }
$bills = Bill::usingSearchString($keyword)->get(); $bills = Bill::usingSearchString($search->keyword)->get();
if ($bills->count()) { if ($bills->count()) {
foreach ($bills as $bill) { foreach ($bills as $bill) {
$results[] = (object)[ $search->results[] = (object) [
'id' => $bill->id, 'id' => $bill->id,
'name' => $bill->bill_number . ' - ' . $bill->contact_name, 'name' => $bill->bill_number . ' - ' . $bill->contact_name,
'type' => trans_choice('general.bills', 1), 'type' => trans_choice('general.bills', 1),
'color' => '#ef3232', 'color' => '#ef3232',
'href' => url('purchases/bills/' . $bill->id), 'href' => route('bills.show', $bill->id),
]; ];
} }
} }
/* /*
$payments = Transaction::type('expense')->usingSearchString($keyword)->get(); $payments = Transaction::expense()->usingSearchString($keyword)->get();
if ($revenues->count()) { if ($revenues->count()) {
foreach ($revenues as $revenue) { foreach ($revenues as $revenue) {
@ -121,20 +122,22 @@ class Search extends Controller
} }
}*/ }*/
$vendors = Contact::vendor()->enabled()->usingSearchString($keyword)->get(); $vendors = Contact::vendor()->enabled()->usingSearchString($search->keyword)->get();
if ($vendors->count()) { if ($vendors->count()) {
foreach ($vendors as $vendor) { foreach ($vendors as $vendor) {
$results[] = (object)[ $search->results[] = (object) [
'id' => $vendor->id, 'id' => $vendor->id,
'name' => $vendor->name, 'name' => $vendor->name,
'type' => trans_choice('general.vendors', 1), 'type' => trans_choice('general.vendors', 1),
'color' => '#efef32', 'color' => '#efef32',
'href' => url('purchases/vendors/' . $vendor->id), 'href' => route('vendors.show', $vendor->id),
]; ];
} }
} }
return response()->json((object) $results); event(new GlobalSearched($search));
return response()->json((object) $search->results);
} }
} }

View File

@ -27,8 +27,10 @@ class Database extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$connection = config('database.default','mysql');
$host = $request['hostname']; $host = $request['hostname'];
$port = env('DB_PORT', '3306'); $port = config("database.connections.$connection.port", '3306');
$database = $request['database']; $database = $request['database'];
$username = $request['username']; $username = $request['username'];
$password = $request['password']; $password = $request['password'];

View File

@ -30,7 +30,7 @@ class Items extends Controller
*/ */
public function create(IRequest $request) public function create(IRequest $request)
{ {
$categories = Category::type('item')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::item()->enabled()->orderBy('name')->pluck('name', 'id');
$taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');

View File

@ -84,19 +84,19 @@ class Item extends Controller
// Download // Download
$steps[] = [ $steps[] = [
'text' => trans('modules.installation.download', ['module' => $name]), 'text' => trans('modules.installation.download', ['module' => $name]),
'url' => url('apps/download') 'url' => route('apps.download')
]; ];
// Unzip // Unzip
$steps[] = [ $steps[] = [
'text' => trans('modules.installation.unzip', ['module' => $name]), 'text' => trans('modules.installation.unzip', ['module' => $name]),
'url' => url('apps/unzip') 'url' => route('apps.unzip')
]; ];
// Download // Download
$steps[] = [ $steps[] = [
'text' => trans('modules.installation.install', ['module' => $name]), 'text' => trans('modules.installation.install', ['module' => $name]),
'url' => url('apps/install') 'url' => route('apps.install')
]; ];
return response()->json([ return response()->json([
@ -269,11 +269,9 @@ class Item extends Controller
public function reviews($alias, Request $request) public function reviews($alias, Request $request)
{ {
$page = $request['page'];
$data = [ $data = [
'query' => [ 'query' => [
'page' => ($page) ? $page : 1, 'page' => $request->get('page', 1),
] ]
]; ];
@ -284,7 +282,7 @@ class Item extends Controller
return response()->json([ return response()->json([
'success' => true, 'success' => true,
'error' => false, 'error' => false,
'data' => null, 'data' => $reviews,
'message' => null, 'message' => null,
'html' => $html, 'html' => $html,
]); ]);

View File

@ -146,7 +146,7 @@ class Tiles extends Controller
] ]
]; ];
$title = trans('modules.search'); $title = trans('general.search');
$modules = $this->getSearchModules($data); $modules = $this->getSearchModules($data);
$installed = Module::all()->pluck('enabled', 'alias')->toArray(); $installed = Module::all()->pluck('enabled', 'alias')->toArray();

View File

@ -27,7 +27,7 @@ class Invoices extends Controller
->accrued()->where('contact_id', user()->contact->id) ->accrued()->where('contact_id', user()->contact->id)
->collect(['invoice_number'=> 'desc']); ->collect(['invoice_number'=> 'desc']);
$categories = collect(Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id')); $categories = collect(Category::income()->enabled()->orderBy('name')->pluck('name', 'id'));
$statuses = $this->getInvoiceStatuses(); $statuses = $this->getInvoiceStatuses();

View File

@ -16,7 +16,7 @@ class Payments extends Controller
*/ */
public function index() public function index()
{ {
$payments = Transaction::type('income')->where('contact_id', '=', user()->contact->id)->paginate(); $payments = Transaction::income()->where('contact_id', '=', user()->contact->id)->paginate();
$payment_methods = Modules::getPaymentMethods('all'); $payment_methods = Modules::getPaymentMethods('all');

View File

@ -41,7 +41,7 @@ class Bills extends Controller
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
$statuses = $this->getBillStatuses(); $statuses = $this->getBillStatuses();
@ -67,7 +67,7 @@ class Bills extends Controller
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();
@ -106,7 +106,7 @@ class Bills extends Controller
$taxes = Tax::enabled()->orderBy('name')->get(); $taxes = Tax::enabled()->orderBy('name')->get();
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
$number = $this->getNextBillNumber(); $number = $this->getNextBillNumber();
@ -202,7 +202,7 @@ class Bills extends Controller
$taxes = Tax::enabled()->orderBy('name')->get(); $taxes = Tax::enabled()->orderBy('name')->get();
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
return view('purchases.bills.edit', compact('bill', 'vendors', 'currencies', 'currency', 'items', 'taxes', 'categories')); return view('purchases.bills.edit', compact('bill', 'vendors', 'currencies', 'currency', 'items', 'taxes', 'categories'));
} }

View File

@ -30,11 +30,11 @@ class Payments extends Controller
*/ */
public function index() public function index()
{ {
$payments = Transaction::type('expense')->with(['account', 'category', 'contact'])->isNotTransfer()->collect(['paid_at'=> 'desc']); $payments = Transaction::expense()->with(['account', 'category', 'contact'])->isNotTransfer()->collect(['paid_at'=> 'desc']);
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id'); $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
@ -68,7 +68,7 @@ class Payments extends Controller
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();
@ -156,7 +156,7 @@ class Payments extends Controller
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('expense')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();

View File

@ -78,7 +78,7 @@ class Vendors extends Controller
} }
// Handle payments // Handle payments
$transactions = Transaction::where('contact_id', $vendor->id)->type('expense')->get(); $transactions = Transaction::where('contact_id', $vendor->id)->expense()->get();
$counts['transactions'] = $transactions->count(); $counts['transactions'] = $transactions->count();

View File

@ -76,7 +76,7 @@ class Customers extends Controller
} }
// Handle transactions // Handle transactions
$transactions = Transaction::where('contact_id', $customer->id)->type('income')->get(); $transactions = Transaction::where('contact_id', $customer->id)->income()->get();
$counts['transactions'] = $transactions->count(); $counts['transactions'] = $transactions->count();

View File

@ -42,7 +42,7 @@ class Invoices extends Controller
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
$statuses = $this->getInvoiceStatuses(); $statuses = $this->getInvoiceStatuses();
@ -68,7 +68,7 @@ class Invoices extends Controller
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();
@ -109,7 +109,7 @@ class Invoices extends Controller
$taxes = Tax::enabled()->orderBy('name')->get(); $taxes = Tax::enabled()->orderBy('name')->get();
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
$number = $this->getNextInvoiceNumber(); $number = $this->getNextInvoiceNumber();
@ -205,7 +205,7 @@ class Invoices extends Controller
$taxes = Tax::enabled()->orderBy('name')->get(); $taxes = Tax::enabled()->orderBy('name')->get();
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
return view('sales.invoices.edit', compact('invoice', 'customers', 'currencies', 'currency', 'items', 'taxes', 'categories')); return view('sales.invoices.edit', compact('invoice', 'customers', 'currencies', 'currency', 'items', 'taxes', 'categories'));
} }

View File

@ -30,11 +30,11 @@ class Revenues extends Controller
*/ */
public function index() public function index()
{ {
$revenues = Transaction::type('income')->with(['account', 'category', 'contact'])->isNotTransfer()->collect(['paid_at'=> 'desc']); $revenues = Transaction::income()->with(['account', 'category', 'contact'])->isNotTransfer()->collect(['paid_at'=> 'desc']);
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id'); $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
@ -68,7 +68,7 @@ class Revenues extends Controller
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();
@ -156,7 +156,7 @@ class Revenues extends Controller
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
$categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();

View File

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Settings;
use App\Abstracts\Http\Controller; use App\Abstracts\Http\Controller;
use App\Models\Setting\Setting; use App\Models\Setting\Setting;
use App\Utilities\Modules as Utility;
use App\Http\Requests\Setting\Module as Request; use App\Http\Requests\Setting\Module as Request;
class Modules extends Controller class Modules extends Controller
@ -54,9 +55,10 @@ class Modules extends Controller
setting()->set($alias . '.' . $key, $value); setting()->set($alias . '.' . $key, $value);
} }
// Save all settings
setting()->save(); setting()->save();
Utility::clearPaymentMethodsCache();
$message = trans('messages.success.updated', ['type' => trans_choice('general.settings', 2)]); $message = trans('messages.success.updated', ['type' => trans_choice('general.settings', 2)]);
$response = [ $response = [

View File

@ -22,11 +22,11 @@ class Modules
if (setting('apps.api_key')) { if (setting('apps.api_key')) {
$categories = Cache::remember('modules.categories.' . language()->getShortCode(), Date::now()->addHour(6), function () { $categories = Cache::remember('modules.categories.' . language()->getShortCode(), Date::now()->addHour(6), function () {
return collect($this->getCategories())->pluck('name', 'slug') return collect($this->getCategories())->pluck('name', 'slug')
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), ''); ->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '*');
}); });
} else { } else {
$categories = collect([ $categories = collect([
'' => trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '*' => trans('general.all_type', ['type' => trans_choice('general.categories', 2)]),
]); ]);
} }

View File

@ -19,7 +19,7 @@ class Notifications
public function compose(View $view) public function compose(View $view)
{ {
// No need to add suggestions in console // No need to add suggestions in console
if (app()->runningInConsole() || !env('APP_INSTALLED') || !user()) { if (app()->runningInConsole() || !config('app.installed') || !user()) {
return; return;
} }

View File

@ -20,7 +20,7 @@ class Suggestions
public function compose(View $view) public function compose(View $view)
{ {
// No need to add suggestions in console // No need to add suggestions in console
if (app()->runningInConsole() || !env('APP_INSTALLED')) { if (app()->runningInConsole() || !config('app.installed')) {
return; return;
} }
@ -31,22 +31,18 @@ class Suggestions
if ($path) { if ($path) {
$suggestions = $this->getSuggestions($path); $suggestions = $this->getSuggestions($path);
if ($suggestions) { if ($suggestions) {
$suggestion_modules = $suggestions->modules; $suggestion_modules = $suggestions->modules;
foreach ($suggestion_modules as $key => $module) { foreach ($suggestion_modules as $key => $module) {
$installed = Module::where('company_id', session('company_id'))->where('alias', $module->alias)->first(); $installed = Module::where('company_id', session('company_id'))->where('alias', $module->alias)->first();
if ($installed) { if ($installed) {
unset($suggestion_modules[$key]); continue;
} }
}
if ($suggestion_modules) { $modules[] = $module;
shuffle($suggestion_modules);
$modules[] = $suggestion_modules[0];
} }
} }
} }

View File

@ -4,7 +4,6 @@ namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use Artisan;
class CreatePermission extends Job class CreatePermission extends Job
{ {
@ -29,8 +28,6 @@ class CreatePermission extends Job
{ {
$permission = Permission::create($this->request->all()); $permission = Permission::create($this->request->all());
Artisan::call('cache:clear');
return $permission; return $permission;
} }
} }

View File

@ -4,7 +4,6 @@ namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use Artisan;
class CreateRole extends Job class CreateRole extends Job
{ {
@ -33,8 +32,6 @@ class CreateRole extends Job
$role->permissions()->attach($this->request->get('permissions')); $role->permissions()->attach($this->request->get('permissions'));
} }
Artisan::call('cache:clear');
return $role; return $role;
} }
} }

View File

@ -44,21 +44,23 @@ class CreateUser extends Job
$user->permissions()->attach($this->request->get('permissions')); $user->permissions()->attach($this->request->get('permissions'));
} }
$user->roles()->attach($this->request->get('roles')); if ($this->request->has('roles')) {
$user->roles()->attach($this->request->get('roles'));
$user->companies()->attach($this->request->get('companies'));
Artisan::call('cache:clear');
// Add User Dashboard
foreach ($user->companies as $company) {
Artisan::call('user:seed', [
'user' => $user->id,
'company' => $company->id,
]);
} }
Artisan::call('cache:clear'); if ($this->request->has('companies')) {
$user->companies()->attach($this->request->get('companies'));
}
// Add User Dashboard
if (!empty($user->companies)) {
foreach ($user->companies as $company) {
Artisan::call('user:seed', [
'user' => $user->id,
'company' => $company->id,
]);
}
}
return $user; return $user;
} }

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Auth; namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use Artisan;
class DeletePermission extends Job class DeletePermission extends Job
{ {
@ -28,8 +27,6 @@ class DeletePermission extends Job
{ {
$this->permission->delete(); $this->permission->delete();
Artisan::call('cache:clear');
return true; return true;
} }
} }

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Auth; namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use Artisan;
class DeleteRole extends Job class DeleteRole extends Job
{ {
@ -28,7 +27,7 @@ class DeleteRole extends Job
{ {
$this->role->delete(); $this->role->delete();
Artisan::call('cache:clear'); $this->role->flushCache();
return true; return true;
} }

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Auth; namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use Artisan;
class DeleteUser extends Job class DeleteUser extends Job
{ {
@ -30,7 +29,7 @@ class DeleteUser extends Job
$this->user->delete(); $this->user->delete();
Artisan::call('cache:clear'); $this->user->flushCache();
return true; return true;
} }

View File

@ -4,7 +4,6 @@ namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use Artisan;
class UpdatePermission extends Job class UpdatePermission extends Job
{ {
@ -33,8 +32,6 @@ class UpdatePermission extends Job
{ {
$this->permission->update($this->request->all()); $this->permission->update($this->request->all());
Artisan::call('cache:clear');
return $this->permission; return $this->permission;
} }
} }

View File

@ -4,7 +4,6 @@ namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use Artisan;
class UpdateRole extends Job class UpdateRole extends Job
{ {
@ -37,8 +36,6 @@ class UpdateRole extends Job
$this->role->permissions()->sync($this->request->get('permissions')); $this->role->permissions()->sync($this->request->get('permissions'));
} }
Artisan::call('cache:clear');
return $this->role; return $this->role;
} }
} }

View File

@ -4,7 +4,6 @@ namespace App\Jobs\Auth;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Models\Auth\User; use App\Models\Auth\User;
use Artisan;
class UpdateUser extends Job class UpdateUser extends Job
{ {
@ -58,8 +57,6 @@ class UpdateUser extends Job
$this->user->companies()->sync($this->request->get('companies')); $this->user->companies()->sync($this->request->get('companies'));
} }
Artisan::call('cache:clear');
return $this->user; return $this->user;
} }

View File

@ -79,8 +79,6 @@ class CreateDocumentTransaction extends Job
{ {
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray(); $currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
$total_amount = $this->model->amount;
$default_amount = (double) $this->request['amount']; $default_amount = (double) $this->request['amount'];
if ($this->model->currency_code == $this->request['currency_code']) { if ($this->model->currency_code == $this->request['currency_code']) {
@ -103,7 +101,7 @@ class CreateDocumentTransaction extends Job
$amount = (double) $convert_amount_model->getAmountConvertedFromDefault(); $amount = (double) $convert_amount_model->getAmountConvertedFromDefault();
} }
$total_amount -= $this->model->paid; $total_amount = $this->model->amount - $this->model->paid;
unset($this->model->reconciled); unset($this->model->reconciled);
// For amount cover integer // For amount cover integer
@ -114,7 +112,7 @@ class CreateDocumentTransaction extends Job
} }
$amount_check = (int) ($amount * $multiplier); $amount_check = (int) ($amount * $multiplier);
$total_amount_check = (int) (round($total_amount, $this->currency->precision) * $multiplier); $total_amount_check = (int) ($total_amount * $multiplier);
if ($amount_check > $total_amount_check) { if ($amount_check > $total_amount_check) {
$error_amount = $total_amount; $error_amount = $total_amount;

View File

@ -4,6 +4,8 @@ namespace App\Jobs\Common;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Models\Common\Dashboard; use App\Models\Common\Dashboard;
use App\Models\Common\Widget;
use App\Utilities\Widgets;
class CreateDashboard extends Job class CreateDashboard extends Job
{ {
@ -28,10 +30,14 @@ class CreateDashboard extends Job
{ {
$this->request['enabled'] = $this->request['enabled'] ?? 1; $this->request['enabled'] = $this->request['enabled'] ?? 1;
$this->dashboard = Dashboard::create($this->request->all()); $this->dashboard = Dashboard::create($this->request->only(['company_id', 'name', 'enabled']));
$this->attachToUser(); $this->attachToUser();
if ($this->request->has('with_widgets')) {
$this->createWidgets();
}
return $this->dashboard; return $this->dashboard;
} }
@ -49,4 +55,24 @@ class CreateDashboard extends Job
$this->dashboard->users()->attach($user); $this->dashboard->users()->attach($user);
} }
protected function createWidgets()
{
$widgets = Widgets::getClasses(false);
$sort = 1;
foreach ($widgets as $class => $name) {
Widget::create([
'company_id' => $this->dashboard->company_id,
'dashboard_id' => $this->dashboard->id,
'class' => $class,
'name' => $name,
'sort' => $sort,
'settings' => (new $class())->getDefaultSettings(),
]);
$sort++;
}
}
} }

View File

@ -35,8 +35,6 @@ class DeleteDashboard extends Job
$this->dashboard->delete(); $this->dashboard->delete();
Artisan::call('cache:clear');
return true; return true;
} }

View File

@ -26,9 +26,11 @@ class AddAdminItems
if ($dashboards->count() > 1) { if ($dashboards->count() > 1) {
$menu->dropdown(trim(trans_choice('general.dashboards', 2)), function ($sub) use ($user, $attr, $dashboards) { $menu->dropdown(trim(trans_choice('general.dashboards', 2)), function ($sub) use ($user, $attr, $dashboards) {
foreach ($dashboards as $key => $dashboard) { foreach ($dashboards as $key => $dashboard) {
$path = (session('dashboard_id') == $dashboard->id) ? '/' : '/?dashboard_id=' . $dashboard->id; if (session('dashboard_id') != $dashboard->id) {
$sub->route('dashboards.switch', $dashboard->name, ['dashboard' => $dashboard->id], $key, $attr);
$sub->url($path, $dashboard->name, $key, $attr); } else {
$sub->url('/', $dashboard->name, $key, $attr);
}
} }
}, 1, [ }, 1, [
'url' => '/', 'url' => '/',

View File

@ -26,7 +26,7 @@ class Version207 extends Listener
// Update .env file // Update .env file
Installer::updateEnv([ Installer::updateEnv([
'MAIL_MAILER' => env('MAIL_DRIVER'), 'MAIL_MAILER' => env('MAIL_DRIVER', config('mail.default')),
]); ]);
} }
} }

View File

@ -2,6 +2,7 @@
namespace App\Models\Auth; namespace App\Models\Auth;
use App\Traits\Tenants;
use Laratrust\Models\LaratrustPermission; use Laratrust\Models\LaratrustPermission;
use Laratrust\Traits\LaratrustPermissionTrait; use Laratrust\Traits\LaratrustPermissionTrait;
use Kyslik\ColumnSortable\Sortable; use Kyslik\ColumnSortable\Sortable;
@ -9,10 +10,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
class Permission extends LaratrustPermission class Permission extends LaratrustPermission
{ {
use LaratrustPermissionTrait, SearchString, Sortable; use LaratrustPermissionTrait, SearchString, Sortable, Tenants;
protected $table = 'permissions'; protected $table = 'permissions';
protected $tenantable = false;
/** /**
* The accessors to append to the model's array form. * The accessors to append to the model's array form.
* *

View File

@ -2,6 +2,7 @@
namespace App\Models\Auth; namespace App\Models\Auth;
use App\Traits\Tenants;
use Laratrust\Models\LaratrustRole; use Laratrust\Models\LaratrustRole;
use Laratrust\Traits\LaratrustRoleTrait; use Laratrust\Traits\LaratrustRoleTrait;
use Kyslik\ColumnSortable\Sortable; use Kyslik\ColumnSortable\Sortable;
@ -9,10 +10,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
class Role extends LaratrustRole class Role extends LaratrustRole
{ {
use LaratrustRoleTrait, SearchString, Sortable; use LaratrustRoleTrait, SearchString, Sortable, Tenants;
protected $table = 'roles'; protected $table = 'roles';
protected $tenantable = false;
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *

View File

@ -2,6 +2,7 @@
namespace App\Models\Auth; namespace App\Models\Auth;
use App\Traits\Tenants;
use App\Notifications\Auth\Reset; use App\Notifications\Auth\Reset;
use App\Traits\Media; use App\Traits\Media;
use Date; use Date;
@ -15,10 +16,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
class User extends Authenticatable class User extends Authenticatable
{ {
use LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media; use LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants;
protected $table = 'users'; protected $table = 'users';
protected $tenantable = false;
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *

View File

@ -96,6 +96,28 @@ class Transaction extends Model
return $query->whereIn($this->table . '.type', (array) $types); return $query->whereIn($this->table . '.type', (array) $types);
} }
/**
* Scope to include only income.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIncome($query)
{
return $query->where($this->table . '.type', '=', 'income');
}
/**
* Scope to include only expense.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeExpense($query)
{
return $query->where($this->table . '.type', '=', 'expense');
}
/** /**
* Get only transfers. * Get only transfers.
* *

View File

@ -3,6 +3,7 @@
namespace App\Models\Common; namespace App\Models\Common;
use App\Traits\Media; use App\Traits\Media;
use App\Traits\Tenants;
use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Kyslik\ColumnSortable\Sortable; use Kyslik\ColumnSortable\Sortable;
@ -10,10 +11,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
class Company extends Eloquent class Company extends Eloquent
{ {
use Media, SearchString, SoftDeletes, Sortable; use Media, SearchString, SoftDeletes, Sortable, Tenants;
protected $table = 'companies'; protected $table = 'companies';
protected $tenantable = false;
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $fillable = ['domain', 'enabled']; protected $fillable = ['domain', 'enabled'];

View File

@ -9,5 +9,7 @@ class Media extends BaseMedia
{ {
use SoftDeletes; use SoftDeletes;
protected $tenantable = false;
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
} }

View File

@ -68,6 +68,50 @@ class Category extends Model
return $query->whereIn($this->table . '.type', (array) $types); return $query->whereIn($this->table . '.type', (array) $types);
} }
/**
* Scope to include only income.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIncome($query)
{
return $query->where($this->table . '.type', '=', 'income');
}
/**
* Scope to include only expense.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeExpense($query)
{
return $query->where($this->table . '.type', '=', 'expense');
}
/**
* Scope to include only item.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeItem($query)
{
return $query->where($this->table . '.type', '=', 'item');
}
/**
* Scope to include only other.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOther($query)
{
return $query->where($this->table . '.type', '=', 'other');
}
public function scopeName($query, $name) public function scopeName($query, $name)
{ {
return $query->where('name', '=', $name); return $query->where('name', '=', $name);
@ -81,6 +125,6 @@ class Category extends Model
*/ */
public function scopeTransfer($query) public function scopeTransfer($query)
{ {
return $query->where('type', 'other')->pluck('id')->first(); return $query->where($this->table . '.type', '=', 'other')->pluck('id')->first();
} }
} }

View File

@ -3,12 +3,17 @@
namespace App\Models\Setting; namespace App\Models\Setting;
use App\Scopes\Company; use App\Scopes\Company;
use App\Traits\Tenants;
use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\Model as Eloquent;
class Setting extends Eloquent class Setting extends Eloquent
{ {
use Tenants;
protected $table = 'settings'; protected $table = 'settings';
protected $tenantable = true;
public $timestamps = false; public $timestamps = false;
/** /**

View File

@ -31,11 +31,11 @@ class App extends Provider
*/ */
public function register() public function register()
{ {
if (env('APP_INSTALLED') && env('APP_DEBUG')) { if (config('app.installed') && config('app.debug')) {
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class); $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
} }
if (env('APP_ENV') !== 'production') { if (config('app.env') !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
} }
} }

View File

@ -30,7 +30,7 @@ class ExpenseSummary extends Report
public function setData() public function setData()
{ {
$transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']); $transactions = $this->applyFilters(Transaction::expense()->isNotTransfer(), ['date_field' => 'paid_at']);
switch ($this->model->settings->basis) { switch ($this->model->settings->basis) {
case 'cash': case 'cash':

View File

@ -16,8 +16,8 @@ class IncomeExpenseSummary extends Report
public function setData() public function setData()
{ {
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']); $income_transactions = $this->applyFilters(Transaction::income()->isNotTransfer(), ['date_field' => 'paid_at']);
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']); $expense_transactions = $this->applyFilters(Transaction::expense()->isNotTransfer(), ['date_field' => 'paid_at']);
switch ($this->model->settings->basis) { switch ($this->model->settings->basis) {
case 'cash': case 'cash':

View File

@ -30,7 +30,7 @@ class IncomeSummary extends Report
public function setData() public function setData()
{ {
$transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']); $transactions = $this->applyFilters(Transaction::income()->isNotTransfer(), ['date_field' => 'paid_at']);
switch ($this->model->settings->basis) { switch ($this->model->settings->basis) {
case 'cash': case 'cash':

View File

@ -40,40 +40,40 @@ class ProfitLoss extends Report
public function setData() public function setData()
{ {
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']); $income_transactions = $this->applyFilters(Transaction::income()->isNotTransfer(), ['date_field' => 'paid_at']);
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']); $expense_transactions = $this->applyFilters(Transaction::expense()->isNotTransfer(), ['date_field' => 'paid_at']);
switch ($this->model->settings->basis) { switch ($this->model->settings->basis) {
case 'cash': case 'cash':
// Revenues // Revenues
$revenues = $income_transactions->get(); $revenues = $income_transactions->get();
$this->setTotals($revenues, 'paid_at', true, $this->tables['income']); $this->setTotals($revenues, 'paid_at', true, $this->tables['income'], false);
// Payments // Payments
$payments = $expense_transactions->get(); $payments = $expense_transactions->get();
$this->setTotals($payments, 'paid_at', true, $this->tables['expense']); $this->setTotals($payments, 'paid_at', true, $this->tables['expense'], false);
break; break;
default: default:
// Invoices // Invoices
$invoices = $this->applyFilters(Invoice::accrued(), ['date_field' => 'invoiced_at'])->get(); $invoices = $this->applyFilters(Invoice::accrued(), ['date_field' => 'invoiced_at'])->get();
Recurring::reflect($invoices, 'invoiced_at'); Recurring::reflect($invoices, 'invoiced_at');
$this->setTotals($invoices, 'invoiced_at', true, $this->tables['income']); $this->setTotals($invoices, 'invoiced_at', true, $this->tables['income'], false);
// Revenues // Revenues
$revenues = $income_transactions->isNotDocument()->get(); $revenues = $income_transactions->isNotDocument()->get();
Recurring::reflect($revenues, 'paid_at'); Recurring::reflect($revenues, 'paid_at');
$this->setTotals($revenues, 'paid_at', true, $this->tables['income']); $this->setTotals($revenues, 'paid_at', true, $this->tables['income'], false);
// Bills // Bills
$bills = $this->applyFilters(Bill::accrued(), ['date_field' => 'billed_at'])->get(); $bills = $this->applyFilters(Bill::accrued(), ['date_field' => 'billed_at'])->get();
Recurring::reflect($bills, 'bill', 'billed_at'); Recurring::reflect($bills, 'bill', 'billed_at');
$this->setTotals($bills, 'billed_at', true, $this->tables['expense']); $this->setTotals($bills, 'billed_at', true, $this->tables['expense'], false);
// Payments // Payments
$payments = $expense_transactions->isNotDocument()->get(); $payments = $expense_transactions->isNotDocument()->get();
Recurring::reflect($payments, 'paid_at'); Recurring::reflect($payments, 'paid_at');
$this->setTotals($payments, 'paid_at', true, $this->tables['expense']); $this->setTotals($payments, 'paid_at', true, $this->tables['expense'], false);
break; break;
} }

View File

@ -47,11 +47,11 @@ class TaxSummary extends Report
switch ($this->model->settings->basis) { switch ($this->model->settings->basis) {
case 'cash': case 'cash':
// Invoice Payments // Invoice Payments
$invoices = $this->applyFilters(Transaction::with(['invoice', 'invoice.totals'])->type('income')->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get(); $invoices = $this->applyFilters(Transaction::with(['invoice', 'invoice.totals'])->income()->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get();
$this->setTotals($invoices, 'paid_at'); $this->setTotals($invoices, 'paid_at');
// Bill Payments // Bill Payments
$bills = $this->applyFilters(Transaction::with(['bill', 'bill.totals'])->type('expense')->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get(); $bills = $this->applyFilters(Transaction::with(['bill', 'bill.totals'])->expense()->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get();
$this->setTotals($bills, 'paid_at'); $this->setTotals($bills, 'paid_at');
break; break;
@ -70,7 +70,7 @@ class TaxSummary extends Report
} }
} }
public function setTotals($items, $date_field, $check_type = false, $table = 'default') public function setTotals($items, $date_field, $check_type = false, $table = 'default', $with_tax = true)
{ {
foreach ($items as $item) { foreach ($items as $item) {
// Make groups extensible // Make groups extensible

View File

@ -17,13 +17,16 @@ class Company implements Scope
*/ */
public function apply(Builder $builder, Model $model) public function apply(Builder $builder, Model $model)
{ {
if (method_exists($model, 'isNotTenantable') && $model->isNotTenantable()) {
return;
}
$table = $model->getTable(); $table = $model->getTable();
// Skip for specific tables // Skip for specific tables
$skip_tables = [ $skip_tables = [
'companies', 'jobs', 'firewall_ips', 'firewall_logs', 'media', 'mediables', 'migrations', 'notifications', 'jobs', 'firewall_ips', 'firewall_logs', 'media', 'mediables', 'migrations', 'notifications', 'role_companies',
'permissions', 'roles', 'role_companies', 'role_permissions', 'sessions', 'users', 'user_companies', 'role_permissions', 'sessions', 'user_companies', 'user_dashboards', 'user_permissions', 'user_roles',
'user_dashboards', 'user_permissions', 'user_roles',
]; ];
if (in_array($table, $skip_tables)) { if (in_array($table, $skip_tables)) {

View File

@ -17,7 +17,7 @@ trait DateTime
$default = 'd M Y'; $default = 'd M Y';
// Make sure it's installed // Make sure it's installed
if (!env('APP_INSTALLED') && (env('APP_ENV') !== 'testing')) { if (!config('app.installed') && (config('app.env') !== 'testing')) {
return $default; return $default;
} }

View File

@ -2,12 +2,10 @@
namespace App\Traits; namespace App\Traits;
use App\Models\Module\Module as Model;
use App\Models\Module\Module; use App\Models\Module\Module;
use App\Traits\SiteApi; use App\Traits\SiteApi;
use App\Utilities\Console; use App\Utilities\Console;
use App\Utilities\Info; use App\Utilities\Info;
use Artisan;
use Cache; use Cache;
use Date; use Date;
use File; use File;
@ -36,10 +34,11 @@ trait Modules
} }
// Get All Modules // Get All Modules
public function getModules() public function getModules($data = [])
{ {
// Get data from cache $key = 'apps.items.page.' . $this->getPageNumber($data);
$items = Cache::get('apps.items');
$items = Cache::get($key);
if (!empty($items)) { if (!empty($items)) {
return $items; return $items;
@ -47,7 +46,7 @@ trait Modules
$items = static::getResponseData('GET', 'apps/items'); $items = static::getResponseData('GET', 'apps/items');
Cache::put('apps.items', $items, Date::now()->addHour()); Cache::put($key, $items, Date::now()->addHour());
return $items; return $items;
} }
@ -62,8 +61,9 @@ trait Modules
public function getDocumentation($alias) public function getDocumentation($alias)
{ {
// Get data from cache $key = 'apps.docs.' . $alias;
$documentation = Cache::get('apps.docs.' . $alias);
$documentation = Cache::get($key);
if (!empty($documentation)) { if (!empty($documentation)) {
return $documentation; return $documentation;
@ -71,15 +71,16 @@ trait Modules
$documentation = static::getResponseData('GET', 'apps/docs/' . $alias); $documentation = static::getResponseData('GET', 'apps/docs/' . $alias);
Cache::put('apps.docs.' . $alias, $documentation, Date::now()->addHour()); Cache::put($key, $documentation, Date::now()->addHour());
return $documentation; return $documentation;
} }
public function getModuleReviews($alias, $data = []) public function getModuleReviews($alias, $data = [])
{ {
// Get data from cache $key = 'apps.' . $alias . '.reviews.page.'. $this->getPageNumber($data);
$reviews = Cache::get('apps.' . $alias . '.reviews');
$reviews = Cache::get($key);
if (!empty($reviews)) { if (!empty($reviews)) {
return $reviews; return $reviews;
@ -87,15 +88,16 @@ trait Modules
$reviews = static::getResponseData('GET', 'apps/' . $alias . '/reviews', $data); $reviews = static::getResponseData('GET', 'apps/' . $alias . '/reviews', $data);
Cache::put('apps.' . $alias . '.reviews', $reviews, Date::now()->addHour()); Cache::put($key, $reviews, Date::now()->addHour());
return $reviews; return $reviews;
} }
public function getCategories() public function getCategories($data = [])
{ {
// Get data from cache $key = 'apps.categories.page.' . $this->getPageNumber($data);
$categories = Cache::get('apps.categories');
$categories = Cache::get($key);
if (!empty($categories)) { if (!empty($categories)) {
return $categories; return $categories;
@ -103,15 +105,16 @@ trait Modules
$categories = static::getResponseData('GET', 'apps/categories'); $categories = static::getResponseData('GET', 'apps/categories');
Cache::put('apps.categories', $categories, Date::now()->addHour()); Cache::put($key, $categories, Date::now()->addHour());
return $categories; return $categories;
} }
public function getModulesByCategory($alias, $data = []) public function getModulesByCategory($alias, $data = [])
{ {
// Get data from cache $key = 'apps.categories.' . $alias . '.page.' . $this->getPageNumber($data);
$category = Cache::get('apps.categories.' . $alias);
$category = Cache::get($key);
if (!empty($category)) { if (!empty($category)) {
return $category; return $category;
@ -119,15 +122,16 @@ trait Modules
$category = static::getResponseData('GET', 'apps/categories/' . $alias, $data); $category = static::getResponseData('GET', 'apps/categories/' . $alias, $data);
Cache::put('apps.categories.' . $alias, $category, Date::now()->addHour()); Cache::put($key, $category, Date::now()->addHour());
return $category; return $category;
} }
public function getVendors() public function getVendors($data = [])
{ {
// Get data from cache $key = 'apps.vendors.page.' . $this->getPageNumber($data);
$vendors = Cache::get('apps.vendors');
$vendors = Cache::get($key);
if (!empty($vendors)) { if (!empty($vendors)) {
return $vendors; return $vendors;
@ -135,15 +139,16 @@ trait Modules
$vendors = static::getResponseData('GET', 'apps/vendors'); $vendors = static::getResponseData('GET', 'apps/vendors');
Cache::put('apps.vendors', $vendors, Date::now()->addHour()); Cache::put($key, $vendors, Date::now()->addHour());
return $vendors; return $vendors;
} }
public function getModulesByVendor($alias, $data = []) public function getModulesByVendor($alias, $data = [])
{ {
// Get data from cache $key = 'apps.vendors.' . $alias . '.page.' . $this->getPageNumber($data);
$vendor = Cache::get('apps.vendors.' . $alias);
$vendor = Cache::get($key);
if (!empty($vendor)) { if (!empty($vendor)) {
return $vendor; return $vendor;
@ -151,7 +156,7 @@ trait Modules
$vendor = static::getResponseData('GET', 'apps/vendors/' . $alias, $data); $vendor = static::getResponseData('GET', 'apps/vendors/' . $alias, $data);
Cache::put('apps.vendors.' . $alias, $vendor, Date::now()->addHour()); Cache::put($key, $vendor, Date::now()->addHour());
return $vendor; return $vendor;
} }
@ -161,44 +166,38 @@ trait Modules
return static::getResponseData('GET', 'apps/my', $data); return static::getResponseData('GET', 'apps/my', $data);
} }
public function getInstalledModules($data = []) public function getInstalledModules()
{ {
$company_id = session('company_id'); $key = 'apps.installed.' . session('company_id');
$cache = 'installed.' . $company_id . '.module'; if ($installed = Cache::get($key)) {
$installed = Cache::get($cache);
if ($installed) {
return $installed; return $installed;
} }
$installed = []; $installed = [];
$modules = Module::all(); Module::all()->each(function($module) use (&$installed) {
$installed_modules = Model::where('company_id', '=', session('company_id'))->pluck('enabled', 'alias')->toArray(); if (!$this->moduleExists($module->alias)) {
return;
foreach ($modules as $module) {
if (!array_key_exists($module->alias, $installed_modules)) {
continue;
} }
$result = $this->getModule($module->alias); if (!$result = $this->getModule($module->alias)) {
return;
if ($result) {
$installed[] = $result;
} }
}
Cache::put($cache, $installed, Date::now()->addHour(6)); $installed[] = $result;
});
Cache::put($key, $installed, Date::now()->addHour(6));
return $installed; return $installed;
} }
public function getPreSaleModules($data = []) public function getPreSaleModules($data = [])
{ {
// Get data from cache $key = 'apps.pre_sale.page.' . $this->getPageNumber($data);
$pre_sale = Cache::get('apps.pre_sale');
$pre_sale = Cache::get($key);
if (!empty($pre_sale)) { if (!empty($pre_sale)) {
return $pre_sale; return $pre_sale;
@ -206,15 +205,16 @@ trait Modules
$pre_sale = static::getResponseData('GET', 'apps/pre_sale', $data); $pre_sale = static::getResponseData('GET', 'apps/pre_sale', $data);
Cache::put('apps.pre_sale', $pre_sale, Date::now()->addHour()); Cache::put($key, $pre_sale, Date::now()->addHour());
return $pre_sale; return $pre_sale;
} }
public function getPaidModules($data = []) public function getPaidModules($data = [])
{ {
// Get data from cache $key = 'apps.paid.page.' . $this->getPageNumber($data);
$paid = Cache::get('apps.paid');
$paid = Cache::get($key);
if (!empty($paid)) { if (!empty($paid)) {
return $paid; return $paid;
@ -222,15 +222,16 @@ trait Modules
$paid = static::getResponseData('GET', 'apps/paid', $data); $paid = static::getResponseData('GET', 'apps/paid', $data);
Cache::put('apps.paid', $paid, Date::now()->addHour()); Cache::put($key, $paid, Date::now()->addHour());
return $paid; return $paid;
} }
public function getNewModules($data = []) public function getNewModules($data = [])
{ {
// Get data from cache $key = 'apps.new.page.' . $this->getPageNumber($data);
$new = Cache::get('apps.new');
$new = Cache::get($key);
if (!empty($new)) { if (!empty($new)) {
return $new; return $new;
@ -238,15 +239,16 @@ trait Modules
$new = static::getResponseData('GET', 'apps/new', $data); $new = static::getResponseData('GET', 'apps/new', $data);
Cache::put('apps.new', $new, Date::now()->addHour()); Cache::put($key, $new, Date::now()->addHour());
return $new; return $new;
} }
public function getFreeModules($data = []) public function getFreeModules($data = [])
{ {
// Get data from cache $key = 'apps.free.page.' . $this->getPageNumber($data);
$free = Cache::get('apps.free');
$free = Cache::get($key);
if (!empty($free)) { if (!empty($free)) {
return $free; return $free;
@ -254,15 +256,16 @@ trait Modules
$free = static::getResponseData('GET', 'apps/free', $data); $free = static::getResponseData('GET', 'apps/free', $data);
Cache::put('apps.free', $free, Date::now()->addHour()); Cache::put($key, $free, Date::now()->addHour());
return $free; return $free;
} }
public function getFeaturedModules($data = []) public function getFeaturedModules($data = [])
{ {
// Get data from cache $key = 'apps.featured.page.' . $this->getPageNumber($data);
$featured = Cache::get('apps.featured');
$featured = Cache::get($key);
if (!empty($featured)) { if (!empty($featured)) {
return $featured; return $featured;
@ -270,7 +273,7 @@ trait Modules
$featured = static::getResponseData('GET', 'apps/featured', $data); $featured = static::getResponseData('GET', 'apps/featured', $data);
Cache::put('apps.featured', $featured, Date::now()->addHour()); Cache::put($key, $featured, Date::now()->addHour());
return $featured; return $featured;
} }
@ -293,11 +296,20 @@ trait Modules
public function downloadModule($path) public function downloadModule($path)
{ {
if (empty($path)) {
return [
'success' => false,
'error' => true,
'message' => trans('modules.errors.download', ['module' => '']),
'data' => null,
];
}
if (!$response = static::getResponse('GET', $path)) { if (!$response = static::getResponse('GET', $path)) {
return [ return [
'success' => false, 'success' => false,
'error' => true, 'error' => true,
'message' => null, 'message' => trans('modules.errors.download', ['module' => '']),
'data' => null, 'data' => null,
]; ];
} }
@ -321,7 +333,7 @@ trait Modules
return [ return [
'success' => false, 'success' => false,
'error' => true, 'error' => true,
'message' => null, 'message' => trans('modules.errors.download', ['module' => '']),
'data' => null, 'data' => null,
]; ];
} }
@ -338,6 +350,15 @@ trait Modules
public function unzipModule($path) public function unzipModule($path)
{ {
if (empty($path)) {
return [
'success' => false,
'error' => true,
'message' => trans('modules.errors.unzip', ['module' => '']),
'data' => null,
];
}
$temp_path = storage_path('app/temp') . '/' . $path; $temp_path = storage_path('app/temp') . '/' . $path;
$file = $temp_path . '/upload.zip'; $file = $temp_path . '/upload.zip';
@ -349,7 +370,7 @@ trait Modules
return [ return [
'success' => false, 'success' => false,
'error' => true, 'error' => true,
'message' => null, 'message' => trans('modules.errors.unzip', ['module' => '']),
'data' => null, 'data' => null,
]; ];
} }
@ -373,9 +394,18 @@ trait Modules
public function installModule($path) public function installModule($path)
{ {
if (empty($path)) {
return [
'success' => false,
'error' => true,
'message' => trans('modules.errors.finish', ['module' => '']),
'data' => null,
];
}
$temp_path = storage_path('app/temp') . '/' . $path; $temp_path = storage_path('app/temp') . '/' . $path;
$modules_path = base_path() . '/modules'; $modules_path = config('module.paths.modules');
// Create modules directory // Create modules directory
if (!File::isDirectory($modules_path)) { if (!File::isDirectory($modules_path)) {
@ -404,13 +434,24 @@ trait Modules
$company_id = session('company_id'); $company_id = session('company_id');
$locale = app()->getLocale(); $locale = app()->getLocale();
Cache::forget('installed.' . $company_id . '.module'); $this->clearModulesCache();
Console::run("module:install {$module->alias} {$company_id} {$locale}"); $command = "module:install {$module->alias} {$company_id} {$locale}";
if (true !== $result = Console::run($command)) {
$message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $module->alias]);
return [
'success' => false,
'error' => true,
'message' => $message,
'data' => null,
];
}
return [ return [
'success' => true, 'success' => true,
'redirect' => url('apps/' . $module->alias), 'redirect' => route('apps.app.show', $module->alias),
'error' => false, 'error' => false,
'message' => null, 'message' => null,
'data' => $data, 'data' => $data,
@ -427,12 +468,9 @@ trait Modules
'version' => $module->get('version'), 'version' => $module->get('version'),
]; ];
Artisan::call('cache:clear');
$module->delete(); $module->delete();
// Cache Data clear $this->clearModulesCache();
File::deleteDirectory(storage_path('framework/cache/data'));
return [ return [
'success' => true, 'success' => true,
@ -454,7 +492,7 @@ trait Modules
$module->enable(); $module->enable();
Artisan::call('cache:clear'); $this->clearModulesCache();
return [ return [
'success' => true, 'success' => true,
@ -476,7 +514,7 @@ trait Modules
$module->disable(); $module->disable();
Artisan::call('cache:clear'); $this->clearModulesCache($alias);
return [ return [
'success' => true, 'success' => true,
@ -488,19 +526,31 @@ trait Modules
public function moduleExists($alias) public function moduleExists($alias)
{ {
$status = false; if (!module($alias) instanceof \Akaunting\Module\Module) {
return false;
if (module($alias) instanceof \Akaunting\Module\Module) {
$status = true;
} }
return $status; return true;
}
public function moduleEnabled($alias)
{
if (!$this->moduleExists($alias)) {
return false;
}
if (!Module::alias($alias)->enabled()->first()) {
return false;
}
return true;
} }
public function loadSuggestions() public function loadSuggestions()
{ {
// Get data from cache $key = 'apps.suggestions';
$data = Cache::get('suggestions');
$data = Cache::get($key);
if (!empty($data)) { if (!empty($data)) {
return $data; return $data;
@ -516,15 +566,16 @@ trait Modules
$data[$suggestion->path] = $suggestion; $data[$suggestion->path] = $suggestion;
} }
Cache::put('suggestions', $data, Date::now()->addHour(6)); Cache::put($key, $data, Date::now()->addHour(6));
return $data; return $data;
} }
public function loadNotifications() public function loadNotifications()
{ {
// Get data from cache $key = 'apps.notifications';
$data = Cache::get('notifications');
$data = Cache::get($key);
if (!empty($data)) { if (!empty($data)) {
return $data; return $data;
@ -540,15 +591,16 @@ trait Modules
$data[$notification->path][] = $notification; $data[$notification->path][] = $notification;
} }
Cache::put('notifications', $data, Date::now()->addHour(6)); Cache::put($key, $data, Date::now()->addHour(6));
return $data; return $data;
} }
public function getSuggestions($path) public function getSuggestions($path)
{ {
// Get data from cache $key = 'apps.suggestions';
$data = Cache::get('suggestions');
$data = Cache::get($key);
if (empty($data)) { if (empty($data)) {
$data = $this->loadSuggestions(); $data = $this->loadSuggestions();
@ -563,8 +615,9 @@ trait Modules
public function getNotifications($path) public function getNotifications($path)
{ {
// Get data from cache $key = 'apps.notifications';
$data = Cache::get('notifications');
$data = Cache::get($key);
if (empty($data)) { if (empty($data)) {
$data = $this->loadNotifications(); $data = $this->loadNotifications();
@ -576,4 +629,24 @@ trait Modules
return false; return false;
} }
public function getPageNumber($data = [])
{
if (empty($data['query']) || empty($data['query']['page'])) {
return 1;
}
return $data['query']['page'];
}
public function clearModulesCache()
{
if (config('module.cache.enabled')) {
Cache::forget(config('module.cache.key'));
}
Cache::forget('apps.notifications');
Cache::forget('apps.suggestions');
Cache::forget('apps.installed.' . session('company_id'));
}
} }

View File

@ -62,7 +62,7 @@ trait Omnipay
public function purchase($invoice, $request, $extra_options = []) public function purchase($invoice, $request, $extra_options = [])
{ {
$default_options = [ $default_options = [
'amount' => $invoice->amount, 'amount' => $invoice->amount - $invoice->paid,
'currency' => $invoice->currency_code, 'currency' => $invoice->currency_code,
'transactionId' => $invoice->id, 'transactionId' => $invoice->id,
'returnUrl' => $this->getReturnUrl($invoice), 'returnUrl' => $this->getReturnUrl($invoice),

View File

@ -2,6 +2,7 @@
namespace App\Traits; namespace App\Traits;
use App\Utilities\Info;
use Exception; use Exception;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\ConnectException;
@ -21,6 +22,7 @@ trait SiteApi
'Referer' => app()->runningInConsole() ? config('app.url') : url('/'), 'Referer' => app()->runningInConsole() ? config('app.url') : url('/'),
'Akaunting' => version('short'), 'Akaunting' => version('short'),
'Language' => language()->getShortCode(), 'Language' => language()->getShortCode(),
'Information' => json_encode(Info::all()),
]; ];
$data = array_merge([ $data = array_merge([

16
app/Traits/Tenants.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace App\Traits;
trait Tenants
{
public function isTenantable()
{
return (isset($this->tenantable) && ($this->tenantable === true));
}
public function isNotTenantable()
{
return !$this->isTenantable();
}
}

View File

@ -2,6 +2,7 @@
namespace App\Utilities; namespace App\Utilities;
use Illuminate\Support\ProcessUtils;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
@ -11,6 +12,8 @@ class Console
{ {
$command = static::formatCommandString($string); $command = static::formatCommandString($string);
logger('Console command:: ' . $command);
$process = Process::fromShellCommandline($command, base_path()); $process = Process::fromShellCommandline($command, base_path());
$process->setTimeout($timeout); $process->setTimeout($timeout);
@ -22,19 +25,21 @@ class Console
$output = $all_output ? $process->getOutput() : $process->getErrorOutput(); $output = $all_output ? $process->getOutput() : $process->getErrorOutput();
logger($output); logger('Console output:: ' . $output);
return $output; return $output;
} }
public static function getPhpBinary() public static function getPhpBinary()
{ {
return (new PhpExecutableFinder)->find(false) ?? 'php'; $bin = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
return !empty($bin) ? $bin : 'php';
} }
public static function getArtisanBinary() public static function getArtisanBinary()
{ {
return defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan'; return defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
} }
public static function formatCommandString($string) public static function formatCommandString($string)

View File

@ -14,6 +14,7 @@ class Info
'api_key' => setting('apps.api_key'), 'api_key' => setting('apps.api_key'),
'companies' => Company::count(), 'companies' => Company::count(),
'users' => User::count(), 'users' => User::count(),
'php_extensions' => static::phpExtensions(),
]); ]);
} }
@ -31,10 +32,21 @@ class Info
return phpversion(); return phpversion();
} }
public static function phpExtensions()
{
return get_loaded_extensions();
}
public static function mysqlVersion() public static function mysqlVersion()
{ {
if (env('DB_CONNECTION') === 'mysql') { static $version;
return DB::selectOne('select version() as mversion')->mversion;
if (empty($version) && (config('database.default') === 'mysql')) {
$version = DB::selectOne('select version() as mversion')->mversion;
}
if (isset($version)) {
return $version;
} }
return 'N/A'; return 'N/A';

View File

@ -183,8 +183,8 @@ class Installer
'database' => $database, 'database' => $database,
'username' => $username, 'username' => $username,
'password' => $password, 'password' => $password,
'driver' => env('DB_CONNECTION', 'mysql'), 'driver' => $connection = config('database.default', 'mysql'),
'charset' => env('DB_CHARSET', 'utf8mb4'), 'charset' => config("database.connections.$connection.charset", 'utf8mb4'),
]); ]);
try { try {
@ -213,7 +213,7 @@ class Installer
'DB_PREFIX' => $prefix, 'DB_PREFIX' => $prefix,
]); ]);
$con = env('DB_CONNECTION', 'mysql'); $con = config('database.default', 'mysql');
// Change current connection // Change current connection
$db = Config::get('database.connections.' . $con); $db = Config::get('database.connections.' . $con);

View File

@ -9,10 +9,8 @@ class Modules
{ {
public static function getPaymentMethods($type = null) public static function getPaymentMethods($type = null)
{ {
$company_id = session('company_id'); $cache_admin = static::getPaymentMethodsCacheKey('admin');
$cache_customer = static::getPaymentMethodsCacheKey('customer');
$cache_admin = 'payment_methods.' . $company_id . '.admin';
$cache_customer = 'payment_methods.' . $company_id . '.customer';
$payment_methods = Cache::get($cache_admin); $payment_methods = Cache::get($cache_admin);
@ -65,6 +63,17 @@ class Modules
return ($payment_methods) ? $payment_methods : []; return ($payment_methods) ? $payment_methods : [];
} }
public static function clearPaymentMethodsCache()
{
Cache::forget(static::getPaymentMethodsCacheKey('admin'));
Cache::forget(static::getPaymentMethodsCacheKey('customer'));
}
public static function getPaymentMethodsCacheKey($type)
{
return 'payment_methods.' . session('company_id') . '.' . $type;
}
protected static function sortPaymentMethods(&$list) protected static function sortPaymentMethods(&$list)
{ {
$sort_order = []; $sort_order = [];

View File

@ -8,7 +8,6 @@ use App\Events\Install\UpdateUnzipped;
use App\Models\Module\Module; use App\Models\Module\Module;
use App\Utilities\Console; use App\Utilities\Console;
use App\Traits\SiteApi; use App\Traits\SiteApi;
use Artisan;
use Cache; use Cache;
use Date; use Date;
use File; use File;
@ -21,7 +20,11 @@ class Updater
public static function clear() public static function clear()
{ {
Artisan::call('cache:clear'); Cache::forget('updates');
Cache::forget('versions');
Cache::forget('apps.notifications');
Cache::forget('apps.suggestions');
Cache::forget('apps.installed.' . session('company_id'));
return true; return true;
} }
@ -161,7 +164,17 @@ class Updater
$versions = Versions::all($modules); $versions = Versions::all($modules);
foreach ($versions as $alias => $latest_version) { foreach ($versions as $alias => $latest_version) {
$installed_version = ($alias == 'core') ? version('short') : module($alias)->get('version'); if ($alias == 'core') {
$installed_version = version('short');
} else {
$module = module($alias);
if (!$module instanceof \Akaunting\Module\Module) {
continue;
}
$installed_version = $module->get('version');
}
if (version_compare($installed_version, $latest_version, '>=')) { if (version_compare($installed_version, $latest_version, '>=')) {
continue; continue;

View File

@ -2,7 +2,6 @@
namespace App\Utilities; namespace App\Utilities;
use Akaunting\Module\Module;
use App\Traits\SiteApi; use App\Traits\SiteApi;
use Cache; use Cache;
use Date; use Date;
@ -89,7 +88,7 @@ class Versions
$module = module($module); $module = module($module);
} }
if (!$module instanceof Module) { if (!$module instanceof \Akaunting\Module\Module) {
continue; continue;
} }

View File

@ -15,7 +15,7 @@ class ExpensesByCategory extends Widget
public function show() public function show()
{ {
Category::with('expense_transactions')->type('expense')->each(function ($category) { Category::with('expense_transactions')->expense()->each(function ($category) {
$amount = 0; $amount = 0;
$this->applyFilters($category->expense_transactions())->each(function ($transaction) use (&$amount) { $this->applyFilters($category->expense_transactions())->each(function ($transaction) use (&$amount) {

View File

@ -15,7 +15,7 @@ class IncomeByCategory extends Widget
public function show() public function show()
{ {
Category::with('income_transactions')->type('income')->each(function ($category) { Category::with('income_transactions')->income()->each(function ($category) {
$amount = 0; $amount = 0;
$this->applyFilters($category->income_transactions())->each(function ($transaction) use (&$amount) { $this->applyFilters($category->income_transactions())->each(function ($transaction) use (&$amount) {

View File

@ -11,7 +11,7 @@ class LatestExpenses extends Widget
public function show() public function show()
{ {
$transactions = $this->applyFilters(Transaction::with('category')->type('expense')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get(); $transactions = $this->applyFilters(Transaction::with('category')->expense()->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
return $this->view('widgets.latest_expenses', [ return $this->view('widgets.latest_expenses', [
'transactions' => $transactions, 'transactions' => $transactions,

View File

@ -11,7 +11,7 @@ class LatestIncome extends Widget
public function show() public function show()
{ {
$transactions = $this->applyFilters(Transaction::with('category')->type('income')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get(); $transactions = $this->applyFilters(Transaction::with('category')->income()->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
return $this->view('widgets.latest_income', [ return $this->view('widgets.latest_income', [
'transactions' => $transactions, 'transactions' => $transactions,

View File

@ -18,7 +18,7 @@ class TotalExpenses extends Widget
{ {
$current = $open = $overdue = 0; $current = $open = $overdue = 0;
$this->applyFilters(Transaction::type('expense')->isNotTransfer())->each(function ($transaction) use (&$current) { $this->applyFilters(Transaction::expense()->isNotTransfer())->each(function ($transaction) use (&$current) {
$current += $transaction->getAmountConvertedToDefault(); $current += $transaction->getAmountConvertedToDefault();
}); });

View File

@ -18,7 +18,7 @@ class TotalIncome extends Widget
{ {
$current = $open = $overdue = 0; $current = $open = $overdue = 0;
$this->applyFilters(Transaction::type('income')->isNotTransfer())->each(function ($transaction) use (&$current) { $this->applyFilters(Transaction::income()->isNotTransfer())->each(function ($transaction) use (&$current) {
$current += $transaction->getAmountConvertedToDefault(); $current += $transaction->getAmountConvertedToDefault();
}); });

View File

@ -24,7 +24,7 @@
"barryvdh/laravel-debugbar": "3.2.*", "barryvdh/laravel-debugbar": "3.2.*",
"barryvdh/laravel-dompdf": "0.*", "barryvdh/laravel-dompdf": "0.*",
"barryvdh/laravel-ide-helper": "2.6.*", "barryvdh/laravel-ide-helper": "2.6.*",
"bkwld/cloner": "3.6.*", "bkwld/cloner": "3.7.*",
"consoletvs/charts": "6.5.*", "consoletvs/charts": "6.5.*",
"dingo/api": "3.0.*", "dingo/api": "3.0.*",
"doctrine/dbal": "2.9.*", "doctrine/dbal": "2.9.*",
@ -40,6 +40,7 @@
"laravel/tinker": "^2.0", "laravel/tinker": "^2.0",
"laravel/ui": "^2.0", "laravel/ui": "^2.0",
"laravelcollective/html": "6.1.*", "laravelcollective/html": "6.1.*",
"league/omnipay": "3.0.*",
"lorisleiva/laravel-search-string": "0.1.*", "lorisleiva/laravel-search-string": "0.1.*",
"maatwebsite/excel": "3.1.*", "maatwebsite/excel": "3.1.*",
"misterphilip/maintenance-mode": "2.0.*", "misterphilip/maintenance-mode": "2.0.*",
@ -55,7 +56,7 @@
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"facade/ignition": "^2.0", "facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1", "fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3", "mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1", "nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5" "phpunit/phpunit": "^8.5"
}, },

1616
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,10 @@ return [
'name' => env('APP_NAME', 'Akaunting'), 'name' => env('APP_NAME', 'Akaunting'),
'installed' => env('APP_INSTALLED', false),
'schedule_time' => env('APP_SCHEDULE_TIME', '9:00'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Environment | Application Environment

View File

@ -22,9 +22,9 @@ return [
*/ */
'stubs' => [ 'stubs' => [
'enabled' => true, 'enabled' => true,
'path' => base_path() . '/app/Console/Stubs/Modules', 'path' => base_path('app/Console/Stubs/Modules'),
'files' => [ 'files' => [
'listeners/install' => 'Listeners/InstallModule.php', 'listeners/install' => 'Listeners/FinishInstallation.php',
'providers/event' => 'Providers/Event.php', 'providers/event' => 'Providers/Event.php',
'routes/admin' => 'Routes/admin.php', 'routes/admin' => 'Routes/admin.php',
'routes/portal' => 'Routes/portal.php', 'routes/portal' => 'Routes/portal.php',
@ -67,7 +67,7 @@ return [
| automatically to list of scanned folders. | automatically to list of scanned folders.
| |
*/ */
'modules' => base_path('modules'), 'modules' => base_path(env('MODULE_PATHS_MODULES', 'modules')),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -77,7 +77,7 @@ return [
| Here you may update the modules assets path. | Here you may update the modules assets path.
| |
*/ */
'assets' => public_path('modules'), 'assets' => public_path(env('MODULE_PATHS_ASSETS', 'modules')),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -88,7 +88,7 @@ return [
| the migration files? | the migration files?
| |
*/ */
'migration' => base_path('database/migrations'), 'migration' => base_path(env('MODULE_PATHS_MIGRATION', 'database/migrations')),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -10,15 +10,15 @@ return [
'minor' => '0', 'minor' => '0',
'patch' => '10', 'patch' => '13',
'build' => '', 'build' => '',
'status' => 'Stable', 'status' => 'Stable',
'date' => '24-April-2020', 'date' => '23-May-2020',
'time' => '22:00', 'time' => '21:00',
'zone' => 'GMT +3', 'zone' => 'GMT +3',

View File

@ -41,7 +41,7 @@ $factory->define(Bill::class, function (Faker $faker) use ($company) {
'currency_code' => setting('default.currency'), 'currency_code' => setting('default.currency'),
'currency_rate' => '1', 'currency_rate' => '1',
'notes' => $faker->text(5), 'notes' => $faker->text(5),
'category_id' => $company->categories()->type('expense')->get()->random(1)->pluck('id')->first(), 'category_id' => $company->categories()->expense()->get()->random(1)->pluck('id')->first(),
'contact_id' => $contact->id, 'contact_id' => $contact->id,
'contact_name' => $contact->name, 'contact_name' => $contact->name,
'contact_email' => $contact->email, 'contact_email' => $contact->email,

View File

@ -42,7 +42,7 @@ $factory->define(Invoice::class, function (Faker $faker) use ($company) {
'currency_code' => setting('default.currency'), 'currency_code' => setting('default.currency'),
'currency_rate' => '1', 'currency_rate' => '1',
'notes' => $faker->text(5), 'notes' => $faker->text(5),
'category_id' => $company->categories()->type('income')->get()->random(1)->pluck('id')->first(), 'category_id' => $company->categories()->income()->get()->random(1)->pluck('id')->first(),
'contact_id' => $contact->id, 'contact_id' => $contact->id,
'contact_name' => $contact->name, 'contact_name' => $contact->name,
'contact_email' => $contact->email, 'contact_email' => $contact->email,

View File

@ -16,7 +16,7 @@ $factory->define(Item::class, function (Faker $faker) use ($company) {
'description' => $faker->text(100), 'description' => $faker->text(100),
'purchase_price' => $faker->randomFloat(2, 10, 20), 'purchase_price' => $faker->randomFloat(2, 10, 20),
'sale_price' => $faker->randomFloat(2, 10, 20), 'sale_price' => $faker->randomFloat(2, 10, 20),
'category_id' => $company->categories()->type('item')->get()->random(1)->pluck('id')->first(), 'category_id' => $company->categories()->item()->get()->random(1)->pluck('id')->first(),
'tax_id' => null, 'tax_id' => null,
'enabled' => $faker->boolean ? 1 : 0, 'enabled' => $faker->boolean ? 1 : 0,
]; ];

View File

@ -31,13 +31,13 @@ $factory->define(Transaction::class, function (Faker $faker) use ($company) {
$factory->state(Transaction::class, 'income', function (Faker $faker) use ($company) { $factory->state(Transaction::class, 'income', function (Faker $faker) use ($company) {
return [ return [
'type' => 'income', 'type' => 'income',
'category_id' => $company->categories()->type('income')->get()->random(1)->pluck('id')->first(), 'category_id' => $company->categories()->income()->get()->random(1)->pluck('id')->first(),
]; ];
}); });
$factory->state(Transaction::class, 'expense', function (Faker $faker) use ($company) { $factory->state(Transaction::class, 'expense', function (Faker $faker) use ($company) {
return [ return [
'type' => 'expense', 'type' => 'expense',
'category_id' => $company->categories()->type('expense')->get()->random(1)->pluck('id')->first(), 'category_id' => $company->categories()->expense()->get()->random(1)->pluck('id')->first(),
]; ];
}); });

View File

@ -3,14 +3,14 @@
namespace Database\Seeds; namespace Database\Seeds;
use App\Abstracts\Model; use App\Abstracts\Model;
use App\Models\Auth\User; use App\Jobs\Common\CreateDashboard;
use App\Models\Common\Widget; use App\Traits\Jobs;
use App\Models\Common\Dashboard;
use App\Utilities\Widgets;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class Dashboards extends Seeder class Dashboards extends Seeder
{ {
use Jobs;
/** /**
* Run the database seeds. * Run the database seeds.
* *
@ -30,29 +30,11 @@ class Dashboards extends Seeder
$user_id = $this->command->argument('user'); $user_id = $this->command->argument('user');
$company_id = $this->command->argument('company'); $company_id = $this->command->argument('company');
$dashboard = Dashboard::create([ $this->dispatch(new CreateDashboard([
'company_id' => $company_id, 'company_id' => $company_id,
'name' => trans_choice('general.dashboards', 1), 'name' => trans_choice('general.dashboards', 1),
'enabled' => 1, 'with_widgets' => true,
]); 'users' => $user_id,
]));
$widgets = Widgets::getClasses(false);
$sort = 1;
foreach ($widgets as $class => $name) {
Widget::create([
'company_id' => $company_id,
'dashboard_id' => $dashboard->id,
'class' => $class,
'name' => $name,
'sort' => $sort,
'settings' => (new $class())->getDefaultSettings(),
]);
$sort++;
}
User::find($user_id)->dashboards()->attach($dashboard->id);
} }
} }

View File

@ -3,7 +3,7 @@
namespace Modules\OfflinePayments\Http\Controllers; namespace Modules\OfflinePayments\Http\Controllers;
use App\Abstracts\Http\Controller; use App\Abstracts\Http\Controller;
use Artisan; use App\Utilities\Modules;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Modules\OfflinePayments\Http\Requests\Setting as Request; use Modules\OfflinePayments\Http\Requests\Setting as Request;
use Modules\OfflinePayments\Http\Requests\SettingGet as GRequest; use Modules\OfflinePayments\Http\Requests\SettingGet as GRequest;
@ -68,7 +68,7 @@ class Settings extends Controller
setting()->save(); setting()->save();
Artisan::call('cache:clear'); Modules::clearPaymentMethodsCache();
$response = [ $response = [
'status' => null, 'status' => null,
@ -152,7 +152,7 @@ class Settings extends Controller
setting()->save(); setting()->save();
Artisan::call('cache:clear'); Modules::clearPaymentMethodsCache();
$message = trans('messages.success.deleted', ['type' => $remove['name']]); $message = trans('messages.success.deleted', ['type' => $remove['name']]);

View File

@ -5,7 +5,7 @@ namespace Modules\OfflinePayments\Listeners;
use App\Events\Module\Installed as Event; use App\Events\Module\Installed as Event;
use App\Traits\Permissions; use App\Traits\Permissions;
class InstallModule class FinishInstallation
{ {
use Permissions; use Permissions;

View File

@ -4,7 +4,7 @@ namespace Modules\OfflinePayments\Listeners;
use App\Events\Module\PaymentMethodShowing as Event; use App\Events\Module\PaymentMethodShowing as Event;
class ShowPaymentMethod class ShowAsPaymentMethod
{ {
/** /**
* Handle the event. * Handle the event.

View File

@ -4,7 +4,7 @@ namespace Modules\OfflinePayments\Listeners;
use App\Events\Module\SettingShowing as Event; use App\Events\Module\SettingShowing as Event;
class ShowSetting class ShowInSettingsPage
{ {
/** /**
* Handle the event. * Handle the event.

View File

@ -3,9 +3,9 @@
namespace Modules\OfflinePayments\Providers; namespace Modules\OfflinePayments\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider;
use Modules\OfflinePayments\Listeners\InstallModule; use Modules\OfflinePayments\Listeners\FinishInstallation;
use Modules\OfflinePayments\Listeners\ShowPaymentMethod; use Modules\OfflinePayments\Listeners\ShowAsPaymentMethod;
use Modules\OfflinePayments\Listeners\ShowSetting; use Modules\OfflinePayments\Listeners\ShowInSettingsPage;
class Event extends Provider class Event extends Provider
{ {
@ -16,13 +16,13 @@ class Event extends Provider
*/ */
protected $listen = [ protected $listen = [
\App\Events\Module\Installed::class => [ \App\Events\Module\Installed::class => [
InstallModule::class, FinishInstallation::class,
], ],
\App\Events\Module\PaymentMethodShowing::class => [ \App\Events\Module\PaymentMethodShowing::class => [
ShowPaymentMethod::class, ShowAsPaymentMethod::class,
], ],
\App\Events\Module\SettingShowing::class => [ \App\Events\Module\SettingShowing::class => [
ShowSetting::class, ShowInSettingsPage::class,
], ],
]; ];
} }

View File

@ -4,7 +4,7 @@ namespace Modules\PaypalStandard\Listeners;
use App\Events\Module\PaymentMethodShowing as Event; use App\Events\Module\PaymentMethodShowing as Event;
class ShowPaymentMethod class ShowAsPaymentMethod
{ {
/** /**
* Handle the event. * Handle the event.

View File

@ -0,0 +1,20 @@
<?php
namespace Modules\PaypalStandard\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider;
use Modules\PaypalStandard\Listeners\ShowAsPaymentMethod;
class Event extends Provider
{
/**
* The event listener mappings for the module.
*
* @var array
*/
protected $listen = [
\App\Events\Module\PaymentMethodShowing::class => [
ShowAsPaymentMethod::class,
],
];
}

View File

@ -3,7 +3,6 @@
namespace Modules\PaypalStandard\Providers; namespace Modules\PaypalStandard\Providers;
use Illuminate\Support\ServiceProvider as Provider; use Illuminate\Support\ServiceProvider as Provider;
use Modules\PaypalStandard\Listeners\ShowPaymentMethod;
class Main extends Provider class Main extends Provider
{ {
@ -16,7 +15,6 @@ class Main extends Provider
{ {
$this->loadTranslations(); $this->loadTranslations();
$this->loadViews(); $this->loadViews();
$this->loadEvents();
} }
/** /**
@ -49,16 +47,6 @@ class Main extends Provider
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'paypal-standard'); $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'paypal-standard');
} }
/**
* Load events.
*
* @return void
*/
public function loadEvents()
{
$this->app['events']->listen(\App\Events\Module\PaymentMethodShowing::class, ShowPaymentMethod::class);
}
/** /**
* Load routes. * Load routes.
* *

View File

@ -5,6 +5,7 @@
"category": "payment-method", "category": "payment-method",
"active": 1, "active": 1,
"providers": [ "providers": [
"Modules\\PaypalStandard\\Providers\\Event",
"Modules\\PaypalStandard\\Providers\\Main" "Modules\\PaypalStandard\\Providers\\Main"
], ],
"aliases": {}, "aliases": {},

View File

@ -4,8 +4,8 @@ namespace Akaunting\Module\Commands;
use App\Models\Module\Module; use App\Models\Module\Module;
use App\Models\Module\ModuleHistory; use App\Models\Module\ModuleHistory;
use Artisan;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
@ -62,7 +62,9 @@ class DeleteCommand extends Command
// Trigger event // Trigger event
event(new \App\Events\Module\Deleted($alias, $company_id)); event(new \App\Events\Module\Deleted($alias, $company_id));
Artisan::call('cache:clear'); if (config('module.cache.enabled')) {
Cache::forget(config('module.cache.key'));
}
$this->info("Module [{$alias}] deleted."); $this->info("Module [{$alias}] deleted.");
} }

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