moved folders to common directory
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Notifications\Expense\Bill as Notification;
|
||||
use App\Utilities\Overrider;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Notifications\Income\Invoice as Notification;
|
||||
use App\Utilities\Overrider;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Expense\BillHistory;
|
||||
use App\Models\Income\InvoiceHistory;
|
||||
use App\Notifications\Expense\Bill as BillNotification;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters\Companies;
|
||||
namespace App\Filters\Common;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters\Items;
|
||||
namespace App\Filters\Common;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Companies;
|
||||
namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Company\Company as Request;
|
||||
use App\Models\Company\Company;
|
||||
use App\Transformers\Company\Company as Transformer;
|
||||
use App\Http\Requests\Common\Company as Request;
|
||||
use App\Models\Common\Company;
|
||||
use App\Transformers\Common\Company as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Companies extends ApiController
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Items;
|
||||
namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Item\Item as Request;
|
||||
use App\Models\Item\Item;
|
||||
use App\Transformers\Item\Item as Transformer;
|
||||
use App\Http\Requests\Common\Item as Request;
|
||||
use App\Models\Common\Item;
|
||||
use App\Transformers\Common\Item as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Items extends ApiController
|
||||
@@ -11,7 +11,7 @@ use App\Models\Expense\BillHistory;
|
||||
use App\Models\Expense\BillItem;
|
||||
use App\Models\Expense\BillPayment;
|
||||
use App\Models\Expense\BillStatus;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Transformers\Expense\Bill as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
@@ -11,9 +11,9 @@ use App\Models\Income\InvoiceHistory;
|
||||
use App\Models\Income\InvoiceItem;
|
||||
use App\Models\Income\InvoicePayment;
|
||||
use App\Models\Income\InvoiceTotal;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Notifications\Item\Item as ItemNotification;
|
||||
use App\Notifications\Common\Item as ItemNotification;
|
||||
use App\Transformers\Income\Invoice as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ class Users extends Controller
|
||||
// Mark item notifications as read
|
||||
foreach ($user->unreadNotifications as $notification) {
|
||||
// Not an item notification
|
||||
if ($notification->getAttribute('type') != 'App\Notifications\Item\Item') {
|
||||
if ($notification->getAttribute('type') != 'App\Notifications\Common\Item') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Events\CompanySwitched;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Company\Company as Request;
|
||||
use App\Models\Company\Company;
|
||||
use App\Http\Requests\Common\Company as Request;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Uploads;
|
||||
|
||||
@@ -26,7 +26,7 @@ class Companies extends Controller
|
||||
$company->setSettings();
|
||||
}
|
||||
|
||||
return view('companies.companies.index', compact('companies'));
|
||||
return view('common.companies.index', compact('companies'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ class Companies extends Controller
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ class Companies extends Controller
|
||||
{
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
|
||||
return view('companies.companies.create', compact('currencies'));
|
||||
return view('common.companies.create', compact('currencies'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ class Companies extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,14 +109,14 @@ class Companies extends Controller
|
||||
|
||||
flash($message)->error();
|
||||
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
$company->setSettings();
|
||||
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
|
||||
return view('companies.companies.edit', compact('company', 'currencies'));
|
||||
return view('common.companies.edit', compact('company', 'currencies'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ class Companies extends Controller
|
||||
|
||||
flash($message)->error();
|
||||
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
// Update company
|
||||
@@ -171,7 +171,7 @@ class Companies extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +189,7 @@ class Companies extends Controller
|
||||
|
||||
flash($message)->error();
|
||||
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
$company->delete();
|
||||
@@ -198,7 +198,7 @@ class Companies extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('companies/companies');
|
||||
return redirect('common/companies');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Banking\Account;
|
||||
@@ -46,7 +46,7 @@ class Dashboard extends Controller
|
||||
|
||||
$latest_expenses = $this->getLatestExpenses();
|
||||
|
||||
return view('dashboard.dashboard.index', compact(
|
||||
return view('common.dashboard.index', compact(
|
||||
'total_incomes',
|
||||
'total_expenses',
|
||||
'total_profit',
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Items;
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Item\Item as Request;
|
||||
use App\Models\Item\Item;
|
||||
use App\Http\Requests\Common\Item as Request;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
@@ -27,7 +27,7 @@ class Items extends Controller
|
||||
$categories = Category::enabled()->type('item')->pluck('name', 'id')
|
||||
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
|
||||
|
||||
return view('items.items.index', compact('items', 'categories'));
|
||||
return view('common.items.index', compact('items', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ class Items extends Controller
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
return redirect('items/items');
|
||||
return redirect('common/items');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ class Items extends Controller
|
||||
|
||||
$taxes = Tax::enabled()->get()->pluck('title', 'id');
|
||||
|
||||
return view('items.items.create', compact('categories', 'taxes'));
|
||||
return view('common.items.create', compact('categories', 'taxes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ class Items extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('items/items');
|
||||
return redirect('common/items');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ class Items extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('items/items/' . $clone->id . '/edit');
|
||||
return redirect('common/items/' . $clone->id . '/edit');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ class Items extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('items/items');
|
||||
return redirect('common/items');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ class Items extends Controller
|
||||
|
||||
$taxes = Tax::enabled()->get()->pluck('title', 'id');
|
||||
|
||||
return view('items.items.edit', compact('item', 'categories', 'taxes'));
|
||||
return view('common.items.edit', compact('item', 'categories', 'taxes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ class Items extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('items/items');
|
||||
return redirect('common/items');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +190,7 @@ class Items extends Controller
|
||||
flash($message)->warning();
|
||||
}
|
||||
|
||||
return redirect('items/items');
|
||||
return redirect('common/items');
|
||||
}
|
||||
|
||||
public function autocomplete()
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Search;
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Banking\Account;
|
||||
@@ -10,7 +10,7 @@ use App\Models\Expense\Vendor;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Income\Revenue;
|
||||
use App\Models\Income\Customer;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Common\Item;
|
||||
|
||||
class Search extends Controller
|
||||
{
|
||||
@@ -43,7 +43,7 @@ class Controller extends BaseController
|
||||
$controller .= kebab_case($arr[0]);
|
||||
|
||||
// Skip ACL
|
||||
$skip = ['dashboard-dashboard', 'customers-dashboard'];
|
||||
$skip = ['common-dashboard', 'customers-dashboard'];
|
||||
if (in_array($controller, $skip)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use App\Models\Expense\BillItem;
|
||||
use App\Models\Expense\BillTotal;
|
||||
use App\Models\Expense\BillHistory;
|
||||
use App\Models\Expense\BillPayment;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
@@ -16,13 +16,13 @@ use App\Models\Income\InvoiceItem;
|
||||
use App\Models\Income\InvoiceTotal;
|
||||
use App\Models\Income\InvoicePayment;
|
||||
use App\Models\Income\InvoiceStatus;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Models\Common\Media;
|
||||
use App\Notifications\Income\Invoice as Notification;
|
||||
use App\Notifications\Item\Item as ItemNotification;
|
||||
use App\Notifications\Common\Item as ItemNotification;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Incomes;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Settings;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Setting\Setting as Request;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Setting;
|
||||
use App\Models\Common\Media;
|
||||
|
||||
@@ -41,9 +41,9 @@ class AdminMenu
|
||||
]);
|
||||
|
||||
// Items
|
||||
if ($user->can('read-items-items')) {
|
||||
if ($user->can('read-common-items')) {
|
||||
$menu->add([
|
||||
'url' => 'items/items',
|
||||
'url' => 'common/items',
|
||||
'title' => trans_choice('general.items', 2),
|
||||
'icon' => 'fa fa-cubes',
|
||||
'order' => 2,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Company;
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Item;
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
@@ -51,7 +51,7 @@ class Header
|
||||
$invoices[$data['invoice_id']] = $data['amount'];
|
||||
$notifications++;
|
||||
break;
|
||||
case 'App\Notifications\Item\Item':
|
||||
case 'App\Notifications\Common\Item':
|
||||
$items[$data['item_id']] = $data['name'];
|
||||
$notifications++;
|
||||
break;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Listeners\Updates;
|
||||
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Models\Expense\BillStatus;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Listeners\Updates;
|
||||
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use Artisan;
|
||||
|
||||
class Version109 extends Listener
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Listeners\Updates;
|
||||
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use DotenvEditor;
|
||||
|
||||
class Version112 extends Listener
|
||||
|
||||
@@ -63,7 +63,7 @@ class Version119 extends Listener
|
||||
|
||||
$migrations = [
|
||||
'\App\Models\Auth\User' => 'picture',
|
||||
'\App\Models\Item\Item' => 'picture',
|
||||
'\App\Models\Common\Item' => 'picture',
|
||||
'\App\Models\Expense\Bill' => 'attachment',
|
||||
'\App\Models\Expense\BillPayment' => 'attachment',
|
||||
'\App\Models\Expense\Payment' => 'attachment',
|
||||
@@ -138,7 +138,7 @@ class Version119 extends Listener
|
||||
}
|
||||
|
||||
if (!empty($path) && Storage::exists($path)) {
|
||||
$company = \App\Models\Company\Company::find($item->company_id);
|
||||
$company = \App\Models\Common\Company::find($item->company_id);
|
||||
|
||||
$media = \App\Models\Common\Media::where('filename', '=', pathinfo(basename($path), PATHINFO_FILENAME))->first();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Listeners\Updates;
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Setting\Category;
|
||||
|
||||
52
app/Listeners/Updates/Version127.php
Normal file
52
app/Listeners/Updates/Version127.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Updates;
|
||||
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Models\Auth\Permission;
|
||||
use File;
|
||||
|
||||
class Version127 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '1.2.7';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UpdateFinished $event)
|
||||
{
|
||||
// Check if should listen
|
||||
if (!$this->check($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update permissions
|
||||
$permissions = Permission::all();
|
||||
foreach ($permissions as $permission) {
|
||||
if (strstr($permission->name, '-companies-companies')) {
|
||||
$permission->name = str_replace('-companies-companies', '-common-companies', $permission->name);
|
||||
$permission->save();
|
||||
}
|
||||
|
||||
if (strstr($permission->name, '-items-items')) {
|
||||
$permission->name = str_replace('-items-items', '-common-items', $permission->name);
|
||||
$permission->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete folders
|
||||
$dirs = ['dashboard', 'search', 'companies', 'items'];
|
||||
foreach ($dirs as $dir) {
|
||||
File::deleteDirectory(app_path('Filters/' . ucfirst($dir)));
|
||||
File::deleteDirectory(app_path('Http/Controllers/' . ucfirst($dir)));
|
||||
File::deleteDirectory(app_path('Http/Requests/' . ucfirst(str_singular($dir))));
|
||||
File::deleteDirectory(app_path('Transformers/' . ucfirst(str_singular($dir))));
|
||||
File::deleteDirectory(resource_path('views/' . $dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class User extends Authenticatable
|
||||
|
||||
public function companies()
|
||||
{
|
||||
return $this->morphToMany('App\Models\Company\Company', 'user', 'user_companies', 'user_id', 'company_id');
|
||||
return $this->morphToMany('App\Models\Common\Company', 'user', 'user_companies', 'user_id', 'company_id');
|
||||
}
|
||||
|
||||
public function customer()
|
||||
|
||||
260
app/Models/Common/Company.php
Normal file
260
app/Models/Common/Company.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Common;
|
||||
|
||||
use Auth;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use App\Traits\Media;
|
||||
|
||||
class Company extends Eloquent
|
||||
{
|
||||
use Filterable, SoftDeletes, Sortable, Media;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['domain', 'enabled'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sortable = ['name', 'domain', 'email', 'enabled', 'created_at'];
|
||||
|
||||
public function accounts()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Account');
|
||||
}
|
||||
|
||||
public function bill_histories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillHistory');
|
||||
}
|
||||
|
||||
public function bill_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillItem');
|
||||
}
|
||||
|
||||
public function bill_payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillPayment');
|
||||
}
|
||||
|
||||
public function bill_statuses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillStatus');
|
||||
}
|
||||
|
||||
public function bills()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\Bill');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Category');
|
||||
}
|
||||
|
||||
public function currencies()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Currency');
|
||||
}
|
||||
|
||||
public function customers()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Customer');
|
||||
}
|
||||
|
||||
public function invoice_histories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceHistory');
|
||||
}
|
||||
|
||||
public function invoice_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceItem');
|
||||
}
|
||||
|
||||
public function invoice_payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoicePayment');
|
||||
}
|
||||
|
||||
public function invoice_statuses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceStatus');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice');
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\Payment');
|
||||
}
|
||||
|
||||
public function recurring()
|
||||
{
|
||||
return $this->hasMany('App\Models\Common\Recurring');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Revenue');
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Setting');
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Tax');
|
||||
}
|
||||
|
||||
public function transfers()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transfer');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Auth\User', 'user', 'user_companies', 'company_id', 'user_id');
|
||||
}
|
||||
|
||||
public function vendors()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\Vendor');
|
||||
}
|
||||
|
||||
public function setSettings()
|
||||
{
|
||||
$settings = $this->settings;
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
list($group, $key) = explode('.', $setting->getAttribute('key'));
|
||||
|
||||
// Load only general settings
|
||||
if ($group != 'general') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $setting->getAttribute('value');
|
||||
|
||||
if (($key == 'company_logo') && empty($value)) {
|
||||
$value = 'public/img/company.png';
|
||||
}
|
||||
|
||||
$this->setAttribute($key, $value);
|
||||
}
|
||||
|
||||
// Set default default company logo if empty
|
||||
if ($this->getAttribute('company_logo') == '') {
|
||||
$this->setAttribute('company_logo', 'public/img/company.png');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the filter provider globally.
|
||||
*
|
||||
* @return ModelFilter
|
||||
*/
|
||||
public function modelFilter()
|
||||
{
|
||||
list($folder, $file) = explode('/', \Route::current()->uri());
|
||||
|
||||
if (empty($folder) || empty($file)) {
|
||||
return $this->provideFilter();
|
||||
}
|
||||
|
||||
$class = '\App\Filters\\' . ucfirst($folder) .'\\' . ucfirst($file);
|
||||
|
||||
return $this->provideFilter($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get all rows filtered, sorted and paginated.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $sort
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCollect($query, $sort = 'name')
|
||||
{
|
||||
$request = request();
|
||||
|
||||
$input = $request->input();
|
||||
$limit = $request->get('limit', setting('general.list_limit', '25'));
|
||||
|
||||
return Auth::user()->companies()->filter($input)->sortable($sort)->paginate($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to only include companies of a given enabled value.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeEnabled($query, $value = 1)
|
||||
{
|
||||
return $query->where('enabled', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by company name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function nameSortable($query, $direction)
|
||||
{
|
||||
return $query->join('settings', 'companies.id', '=', 'settings.company_id')
|
||||
->where('key', 'general.company_name')
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by company email
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function emailSortable($query, $direction)
|
||||
{
|
||||
return $query->join('settings', 'companies.id', '=', 'settings.company_id')
|
||||
->where('key', 'general.company_email')
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyLogoAttribute()
|
||||
{
|
||||
return $this->getMedia('company_logo')->last();
|
||||
}
|
||||
}
|
||||
158
app/Models/Common/Item.php
Normal file
158
app/Models/Common/Item.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Common;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Traits\Currencies;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use App\Traits\Media;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use Cloneable, Currencies, Eloquence, Media;
|
||||
|
||||
protected $table = 'items';
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['item_id'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'sku', 'description', 'sale_price', 'purchase_price', 'quantity', 'category_id', 'tax_id', 'enabled'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $sortable = ['name', 'category', 'quantity', 'sale_price', 'purchase_price', 'enabled'];
|
||||
|
||||
/**
|
||||
* Searchable rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $searchableColumns = [
|
||||
'name' => 10,
|
||||
'sku' => 5,
|
||||
'description' => 2,
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Category');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Tax');
|
||||
}
|
||||
|
||||
public function bill_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillItem');
|
||||
}
|
||||
|
||||
public function invoice_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceItem');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sale price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setSalePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['sale_price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert purchase price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPurchasePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['purchase_price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getItemIdAttribute()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope autocomplete.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $filter
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAutocomplete($query, $filter)
|
||||
{
|
||||
return $query->where(function ($query) use ($filter) {
|
||||
foreach ($filter as $key => $value) {
|
||||
$query->orWhere($key, 'LIKE', "%" . $value . "%");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope quantity.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeQuantity($query)
|
||||
{
|
||||
return $query->where('quantity', '>', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by category name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function categorySortable($query, $direction)
|
||||
{
|
||||
return $query->join('categories', 'categories.id', '=', 'items.category_id')
|
||||
->orderBy('name', $direction)
|
||||
->select('items.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPictureAttribute($value)
|
||||
{
|
||||
if (!empty($value) && !$this->hasMedia('picture')) {
|
||||
return $value;
|
||||
} elseif (!$this->hasMedia('picture')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('picture')->last();
|
||||
}
|
||||
}
|
||||
@@ -2,259 +2,9 @@
|
||||
|
||||
namespace App\Models\Company;
|
||||
|
||||
use Auth;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use App\Traits\Media;
|
||||
use App\Models\Common\Company as C;
|
||||
|
||||
class Company extends Eloquent
|
||||
{
|
||||
use Filterable, SoftDeletes, Sortable, Media;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['domain', 'enabled'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sortable = ['name', 'domain', 'email', 'enabled', 'created_at'];
|
||||
|
||||
public function accounts()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Account');
|
||||
}
|
||||
|
||||
public function bill_histories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillHistory');
|
||||
}
|
||||
|
||||
public function bill_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillItem');
|
||||
}
|
||||
|
||||
public function bill_payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillPayment');
|
||||
}
|
||||
|
||||
public function bill_statuses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillStatus');
|
||||
}
|
||||
|
||||
public function bills()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\Bill');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Category');
|
||||
}
|
||||
|
||||
public function currencies()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Currency');
|
||||
}
|
||||
|
||||
public function customers()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Customer');
|
||||
}
|
||||
|
||||
public function invoice_histories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceHistory');
|
||||
}
|
||||
|
||||
public function invoice_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceItem');
|
||||
}
|
||||
|
||||
public function invoice_payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoicePayment');
|
||||
}
|
||||
|
||||
public function invoice_statuses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceStatus');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice');
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Item\Item');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\Payment');
|
||||
}
|
||||
|
||||
public function recurring()
|
||||
{
|
||||
return $this->hasMany('App\Models\Common\Recurring');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Revenue');
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Setting');
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Tax');
|
||||
}
|
||||
|
||||
public function transfers()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transfer');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Auth\User', 'user', 'user_companies', 'company_id', 'user_id');
|
||||
}
|
||||
|
||||
public function vendors()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\Vendor');
|
||||
}
|
||||
|
||||
public function setSettings()
|
||||
{
|
||||
$settings = $this->settings;
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
list($group, $key) = explode('.', $setting->getAttribute('key'));
|
||||
|
||||
// Load only general settings
|
||||
if ($group != 'general') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $setting->getAttribute('value');
|
||||
|
||||
if (($key == 'company_logo') && empty($value)) {
|
||||
$value = 'public/img/company.png';
|
||||
}
|
||||
|
||||
$this->setAttribute($key, $value);
|
||||
}
|
||||
|
||||
// Set default default company logo if empty
|
||||
if ($this->getAttribute('company_logo') == '') {
|
||||
$this->setAttribute('company_logo', 'public/img/company.png');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the filter provider globally.
|
||||
*
|
||||
* @return ModelFilter
|
||||
*/
|
||||
public function modelFilter()
|
||||
{
|
||||
list($folder, $file) = explode('/', \Route::current()->uri());
|
||||
|
||||
if (empty($folder) || empty($file)) {
|
||||
return $this->provideFilter();
|
||||
}
|
||||
|
||||
$class = '\App\Filters\\' . ucfirst($folder) .'\\' . ucfirst($file);
|
||||
|
||||
return $this->provideFilter($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get all rows filtered, sorted and paginated.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $sort
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCollect($query, $sort = 'name')
|
||||
{
|
||||
$request = request();
|
||||
|
||||
$input = $request->input();
|
||||
$limit = $request->get('limit', setting('general.list_limit', '25'));
|
||||
|
||||
return Auth::user()->companies()->filter($input)->sortable($sort)->paginate($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to only include companies of a given enabled value.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeEnabled($query, $value = 1)
|
||||
{
|
||||
return $query->where('enabled', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by company name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function nameSortable($query, $direction)
|
||||
{
|
||||
return $query->join('settings', 'companies.id', '=', 'settings.company_id')
|
||||
->where('key', 'general.company_name')
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by company email
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function emailSortable($query, $direction)
|
||||
{
|
||||
return $query->join('settings', 'companies.id', '=', 'settings.company_id')
|
||||
->where('key', 'general.company_email')
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyLogoAttribute()
|
||||
{
|
||||
return $this->getMedia('company_logo')->last();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @deprecated since 1.2.7 version. use Common\Company instead.
|
||||
*/
|
||||
class Company extends C {}
|
||||
|
||||
@@ -26,7 +26,7 @@ class BillHistory extends Model
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Item\Item');
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
|
||||
@@ -26,7 +26,7 @@ class BillItem extends Model
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Item\Item');
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
|
||||
@@ -39,7 +39,7 @@ class BillPayment extends Model
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Item\Item');
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
|
||||
@@ -26,7 +26,7 @@ class InvoiceHistory extends Model
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Item\Item');
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
|
||||
@@ -26,7 +26,7 @@ class InvoiceItem extends Model
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Item\Item');
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
|
||||
@@ -39,7 +39,7 @@ class InvoicePayment extends Model
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Item\Item');
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
|
||||
@@ -2,157 +2,9 @@
|
||||
|
||||
namespace App\Models\Item;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Traits\Currencies;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use App\Traits\Media;
|
||||
use App\Models\Common\Item as I;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use Cloneable, Currencies, Eloquence, Media;
|
||||
|
||||
protected $table = 'items';
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['item_id'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'sku', 'description', 'sale_price', 'purchase_price', 'quantity', 'category_id', 'tax_id', 'enabled'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $sortable = ['name', 'category', 'quantity', 'sale_price', 'purchase_price', 'enabled'];
|
||||
|
||||
/**
|
||||
* Searchable rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $searchableColumns = [
|
||||
'name' => 10,
|
||||
'sku' => 5,
|
||||
'description' => 2,
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Category');
|
||||
}
|
||||
|
||||
public function tax()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Tax');
|
||||
}
|
||||
|
||||
public function bill_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillItem');
|
||||
}
|
||||
|
||||
public function invoice_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceItem');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sale price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setSalePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['sale_price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert purchase price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPurchasePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['purchase_price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getItemIdAttribute()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope autocomplete.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $filter
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAutocomplete($query, $filter)
|
||||
{
|
||||
return $query->where(function ($query) use ($filter) {
|
||||
foreach ($filter as $key => $value) {
|
||||
$query->orWhere($key, 'LIKE', "%" . $value . "%");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope quantity.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeQuantity($query)
|
||||
{
|
||||
return $query->where('quantity', '>', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by category name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function categorySortable($query, $direction)
|
||||
{
|
||||
return $query->join('categories', 'categories.id', '=', 'items.category_id')
|
||||
->orderBy('name', $direction)
|
||||
->select('items.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPictureAttribute($value)
|
||||
{
|
||||
if (!empty($value) && !$this->hasMedia('picture')) {
|
||||
return $value;
|
||||
} elseif (!$this->hasMedia('picture')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('picture')->last();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @deprecated since 1.2.7 version. use Common\Item instead.
|
||||
*/
|
||||
class Item extends I {}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Model extends Eloquent
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Company\Company');
|
||||
return $this->belongsTo('App\Models\Common\Company');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class Category extends Model
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Item\Item');
|
||||
return $this->hasMany('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
|
||||
@@ -43,7 +43,7 @@ class Setting extends Model
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Company\Company');
|
||||
return $this->belongsTo('App\Models\Common\Company');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ class Tax extends Model
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany('App\Models\Item\Item');
|
||||
return $this->hasMany('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function bill_items()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Item;
|
||||
namespace App\Notifications\Common;
|
||||
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Company\Company as Model;
|
||||
use App\Models\Common\Company as Model;
|
||||
use Artisan;
|
||||
use Auth;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
'App\Listeners\Updates\Version119',
|
||||
'App\Listeners\Updates\Version120',
|
||||
'App\Listeners\Updates\Version126',
|
||||
'App\Listeners\Updates\Version127',
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => [
|
||||
'App\Listeners\Auth\Login',
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Company\Company;
|
||||
|
||||
use App\Models\Common\Company;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ObserverServiceProvider extends ServiceProvider
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Company;
|
||||
namespace App\Transformers\Common;
|
||||
|
||||
use App\Models\Company\Company as Model;
|
||||
use App\Models\Common\Company as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Company extends TransformerAbstract
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Item;
|
||||
namespace App\Transformers\Common;
|
||||
|
||||
use App\Transformers\Setting\Category;
|
||||
use App\Transformers\Setting\Tax;
|
||||
use App\Models\Item\Item as Model;
|
||||
use App\Models\Common\Item as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Item extends TransformerAbstract
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Utilities;
|
||||
|
||||
use DB;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
|
||||
class Info
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Common\Company;
|
||||
use Artisan;
|
||||
use Config;
|
||||
use DB;
|
||||
|
||||
Reference in New Issue
Block a user