diff --git a/app/Console/Commands/BillReminder.php b/app/Console/Commands/BillReminder.php index 77362cf31..1df9e6a4e 100644 --- a/app/Console/Commands/BillReminder.php +++ b/app/Console/Commands/BillReminder.php @@ -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; diff --git a/app/Console/Commands/InvoiceReminder.php b/app/Console/Commands/InvoiceReminder.php index cc459c114..a2c097260 100644 --- a/app/Console/Commands/InvoiceReminder.php +++ b/app/Console/Commands/InvoiceReminder.php @@ -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; diff --git a/app/Console/Commands/RecurringCheck.php b/app/Console/Commands/RecurringCheck.php index 323cc223c..8b41c499a 100644 --- a/app/Console/Commands/RecurringCheck.php +++ b/app/Console/Commands/RecurringCheck.php @@ -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; diff --git a/app/Filters/Companies/Companies.php b/app/Filters/Common/Companies.php similarity index 92% rename from app/Filters/Companies/Companies.php rename to app/Filters/Common/Companies.php index 4bd996773..0e7944fec 100644 --- a/app/Filters/Companies/Companies.php +++ b/app/Filters/Common/Companies.php @@ -1,6 +1,6 @@ unreadNotifications as $notification) { // Not an item notification - if ($notification->getAttribute('type') != 'App\Notifications\Item\Item') { + if ($notification->getAttribute('type') != 'App\Notifications\Common\Item') { continue; } diff --git a/app/Http/Controllers/Companies/Companies.php b/app/Http/Controllers/Common/Companies.php similarity index 89% rename from app/Http/Controllers/Companies/Companies.php rename to app/Http/Controllers/Common/Companies.php index 2b73a56dc..7b1b3e6a4 100644 --- a/app/Http/Controllers/Companies/Companies.php +++ b/app/Http/Controllers/Common/Companies.php @@ -1,11 +1,11 @@ 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'); } /** diff --git a/app/Http/Controllers/Dashboard/Dashboard.php b/app/Http/Controllers/Common/Dashboard.php similarity index 99% rename from app/Http/Controllers/Dashboard/Dashboard.php rename to app/Http/Controllers/Common/Dashboard.php index 9d7269a2e..50ec8bbcb 100644 --- a/app/Http/Controllers/Dashboard/Dashboard.php +++ b/app/Http/Controllers/Common/Dashboard.php @@ -1,6 +1,6 @@ getLatestExpenses(); - return view('dashboard.dashboard.index', compact( + return view('common.dashboard.index', compact( 'total_incomes', 'total_expenses', 'total_profit', diff --git a/app/Http/Controllers/Items/Items.php b/app/Http/Controllers/Common/Items.php similarity index 93% rename from app/Http/Controllers/Items/Items.php rename to app/Http/Controllers/Common/Items.php index 4e81b3b9f..91aa23208 100644 --- a/app/Http/Controllers/Items/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -1,10 +1,10 @@ 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() diff --git a/app/Http/Controllers/Search/Search.php b/app/Http/Controllers/Common/Search.php similarity index 98% rename from app/Http/Controllers/Search/Search.php rename to app/Http/Controllers/Common/Search.php index d7dfd13f6..cb192a58a 100644 --- a/app/Http/Controllers/Search/Search.php +++ b/app/Http/Controllers/Common/Search.php @@ -1,6 +1,6 @@ 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, diff --git a/app/Http/Requests/Company/Company.php b/app/Http/Requests/Common/Company.php similarity index 95% rename from app/Http/Requests/Company/Company.php rename to app/Http/Requests/Common/Company.php index afd381416..70c644366 100644 --- a/app/Http/Requests/Company/Company.php +++ b/app/Http/Requests/Common/Company.php @@ -1,6 +1,6 @@ '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(); diff --git a/app/Listeners/Updates/Version120.php b/app/Listeners/Updates/Version120.php index eed244fe3..0b864f31a 100644 --- a/app/Listeners/Updates/Version120.php +++ b/app/Listeners/Updates/Version120.php @@ -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; diff --git a/app/Listeners/Updates/Version127.php b/app/Listeners/Updates/Version127.php new file mode 100644 index 000000000..d3b407d5f --- /dev/null +++ b/app/Listeners/Updates/Version127.php @@ -0,0 +1,52 @@ +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)); + } + } +} diff --git a/app/Models/Auth/User.php b/app/Models/Auth/User.php index 0a985bbc5..ae51beff0 100644 --- a/app/Models/Auth/User.php +++ b/app/Models/Auth/User.php @@ -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() diff --git a/app/Models/Common/Company.php b/app/Models/Common/Company.php new file mode 100644 index 000000000..297c7abdd --- /dev/null +++ b/app/Models/Common/Company.php @@ -0,0 +1,260 @@ +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(); + } +} diff --git a/app/Models/Common/Item.php b/app/Models/Common/Item.php new file mode 100644 index 000000000..04acf3adc --- /dev/null +++ b/app/Models/Common/Item.php @@ -0,0 +1,158 @@ + 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(); + } +} diff --git a/app/Models/Company/Company.php b/app/Models/Company/Company.php index eb2d11247..93df1389f 100644 --- a/app/Models/Company/Company.php +++ b/app/Models/Company/Company.php @@ -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 {} diff --git a/app/Models/Expense/BillHistory.php b/app/Models/Expense/BillHistory.php index b8f4fd0bd..548d99e0c 100644 --- a/app/Models/Expense/BillHistory.php +++ b/app/Models/Expense/BillHistory.php @@ -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() diff --git a/app/Models/Expense/BillItem.php b/app/Models/Expense/BillItem.php index 986510e3b..98a88e15c 100644 --- a/app/Models/Expense/BillItem.php +++ b/app/Models/Expense/BillItem.php @@ -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() diff --git a/app/Models/Expense/BillPayment.php b/app/Models/Expense/BillPayment.php index 4a1ee3f44..75a2b1ad5 100644 --- a/app/Models/Expense/BillPayment.php +++ b/app/Models/Expense/BillPayment.php @@ -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() diff --git a/app/Models/Income/InvoiceHistory.php b/app/Models/Income/InvoiceHistory.php index 64bcd1663..1d61f5be8 100644 --- a/app/Models/Income/InvoiceHistory.php +++ b/app/Models/Income/InvoiceHistory.php @@ -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() diff --git a/app/Models/Income/InvoiceItem.php b/app/Models/Income/InvoiceItem.php index b50ee2cf6..39477ee66 100644 --- a/app/Models/Income/InvoiceItem.php +++ b/app/Models/Income/InvoiceItem.php @@ -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() diff --git a/app/Models/Income/InvoicePayment.php b/app/Models/Income/InvoicePayment.php index 0a257684a..c8f4ea317 100644 --- a/app/Models/Income/InvoicePayment.php +++ b/app/Models/Income/InvoicePayment.php @@ -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() diff --git a/app/Models/Item/Item.php b/app/Models/Item/Item.php index f9729625c..fa65cf8a8 100644 --- a/app/Models/Item/Item.php +++ b/app/Models/Item/Item.php @@ -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 {} diff --git a/app/Models/Model.php b/app/Models/Model.php index 0ffda8779..1010b5e7f 100644 --- a/app/Models/Model.php +++ b/app/Models/Model.php @@ -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'); } /** diff --git a/app/Models/Setting/Category.php b/app/Models/Setting/Category.php index 5aa3f418f..11c715ccf 100644 --- a/app/Models/Setting/Category.php +++ b/app/Models/Setting/Category.php @@ -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() diff --git a/app/Models/Setting/Setting.php b/app/Models/Setting/Setting.php index 82cc0d8c5..c025f58ff 100644 --- a/app/Models/Setting/Setting.php +++ b/app/Models/Setting/Setting.php @@ -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'); } /** diff --git a/app/Models/Setting/Tax.php b/app/Models/Setting/Tax.php index 30dd5b67b..9d19d8776 100644 --- a/app/Models/Setting/Tax.php +++ b/app/Models/Setting/Tax.php @@ -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() diff --git a/app/Notifications/Item/Item.php b/app/Notifications/Common/Item.php similarity index 97% rename from app/Notifications/Item/Item.php rename to app/Notifications/Common/Item.php index 83e74c08d..208edb6e9 100644 --- a/app/Notifications/Item/Item.php +++ b/app/Notifications/Common/Item.php @@ -1,6 +1,6 @@ [ 'App\Listeners\Auth\Login', diff --git a/app/Providers/ObserverServiceProvider.php b/app/Providers/ObserverServiceProvider.php index edb3ad306..a0aaef112 100644 --- a/app/Providers/ObserverServiceProvider.php +++ b/app/Providers/ObserverServiceProvider.php @@ -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 diff --git a/app/Transformers/Company/Company.php b/app/Transformers/Common/Company.php similarity index 92% rename from app/Transformers/Company/Company.php rename to app/Transformers/Common/Company.php index b69718764..acfdce73d 100644 --- a/app/Transformers/Company/Company.php +++ b/app/Transformers/Common/Company.php @@ -1,8 +1,8 @@ =5.2 <6.0", "php": ">=5.5.9" }, + "require-dev": { + "laravel/framework": ">=5.2 <6.0", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": ">=4.8, <6" + }, "type": "library", "extra": { "laravel": { @@ -181,7 +186,7 @@ "laravel", "persistent" ], - "time": "2018-04-19T11:11:57+00:00" + "time": "2018-06-01T07:02:27+00:00" }, { "name": "akaunting/version", @@ -822,30 +827,30 @@ }, { "name": "doctrine/annotations", - "version": "v1.4.0", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", - "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -886,37 +891,41 @@ "docblock", "parser" ], - "time": "2017-02-24T16:22:25+00:00" + "time": "2017-12-06T07:11:42+00:00" }, { "name": "doctrine/cache", - "version": "v1.6.2", + "version": "v1.7.1", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", - "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a", "shasum": "" }, "require": { - "php": "~5.5|~7.0" + "php": "~7.1" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "phpunit/phpunit": "~4.8|~5.0", - "predis/predis": "~1.0", - "satooshi/php-coveralls": "~0.6" + "alcaeus/mongo-php-adapter": "^1.1", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^5.7", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -956,24 +965,24 @@ "cache", "caching" ], - "time": "2017-07-22T12:49:21+00:00" + "time": "2017-08-25T07:02:50+00:00" }, { "name": "doctrine/collections", - "version": "v1.4.0", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba" + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/1a4fb7e902202c33cce8c55989b945612943c2ba", - "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba", + "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { "doctrine/coding-standard": "~0.1@dev", @@ -1023,7 +1032,7 @@ "collections", "iterator" ], - "time": "2017-01-03T10:49:41+00:00" + "time": "2017-07-22T10:37:32+00:00" }, { "name": "doctrine/common", @@ -1171,33 +1180,33 @@ }, { "name": "doctrine/inflector", - "version": "v1.1.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" + "reference": "5527a48b7313d15261292c149e55e26eae771b0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Inflector\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" } }, "notification-url": "https://packagist.org/downloads/", @@ -1234,7 +1243,7 @@ "singularize", "string" ], - "time": "2015-11-06T14:35:42+00:00" + "time": "2018-01-09T20:05:19+00:00" }, { "name": "doctrine/lexer", @@ -2766,16 +2775,16 @@ }, { "name": "nesbot/carbon", - "version": "1.28.0", + "version": "1.29.2", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "00149d95fc91ef10f19d3a66889bc3bb7500fa7b" + "reference": "ed6aa898982f441ccc9b2acdec51490f2bc5d337" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/00149d95fc91ef10f19d3a66889bc3bb7500fa7b", - "reference": "00149d95fc91ef10f19d3a66889bc3bb7500fa7b", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ed6aa898982f441ccc9b2acdec51490f2bc5d337", + "reference": "ed6aa898982f441ccc9b2acdec51490f2bc5d337", "shasum": "" }, "require": { @@ -2810,28 +2819,28 @@ "datetime", "time" ], - "time": "2018-05-18T15:26:18+00:00" + "time": "2018-05-29T15:23:46+00:00" }, { "name": "nikic/php-parser", - "version": "v3.1.5", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" + "reference": "35b8caf75e791ba1b2d24fec1552168d72692b12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/35b8caf75e791ba1b2d24fec1552168d72692b12", + "reference": "35b8caf75e791ba1b2d24fec1552168d72692b12", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.5" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "phpunit/phpunit": "^6.5 || ^7.0" }, "bin": [ "bin/php-parse" @@ -2839,7 +2848,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2861,7 +2870,7 @@ "parser", "php" ], - "time": "2018-02-28T20:30:58+00:00" + "time": "2018-06-03T11:33:10+00:00" }, { "name": "nwidart/laravel-menus", @@ -3084,16 +3093,16 @@ }, { "name": "phenx/php-svg-lib", - "version": "v0.3", + "version": "v0.3.2", "source": { "type": "git", "url": "https://github.com/PhenX/php-svg-lib.git", - "reference": "a85f7fe9fe08d093a4a8583cdd306b553ff918aa" + "reference": "ccc46ef6340d4b8a4a68047e68d8501ea961442c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/a85f7fe9fe08d093a4a8583cdd306b553ff918aa", - "reference": "a85f7fe9fe08d093a4a8583cdd306b553ff918aa", + "url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/ccc46ef6340d4b8a4a68047e68d8501ea961442c", + "reference": "ccc46ef6340d4b8a4a68047e68d8501ea961442c", "shasum": "" }, "require": { @@ -3120,7 +3129,7 @@ ], "description": "A library to read, parse and export to PDF SVG files.", "homepage": "https://github.com/PhenX/php-svg-lib", - "time": "2017-05-24T10:07:27+00:00" + "time": "2018-06-03T10:10:03+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -3490,16 +3499,16 @@ }, { "name": "psy/psysh", - "version": "v0.9.4", + "version": "v0.9.5", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "4d969a0e08e1e05e7207c07cb4207017ecc9a331" + "reference": "0951e91ac04ca28cf317f3997a0adfc319e80106" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/4d969a0e08e1e05e7207c07cb4207017ecc9a331", - "reference": "4d969a0e08e1e05e7207c07cb4207017ecc9a331", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/0951e91ac04ca28cf317f3997a0adfc319e80106", + "reference": "0951e91ac04ca28cf317f3997a0adfc319e80106", "shasum": "" }, "require": { @@ -3558,7 +3567,7 @@ "interactive", "shell" ], - "time": "2018-05-22T06:48:07+00:00" + "time": "2018-06-02T16:39:22+00:00" }, { "name": "ramsey/uuid", @@ -4021,7 +4030,7 @@ }, { "name": "symfony/class-loader", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/class-loader.git", @@ -4077,7 +4086,7 @@ }, { "name": "symfony/console", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/console.git", @@ -4146,7 +4155,7 @@ }, { "name": "symfony/css-selector", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -4199,7 +4208,7 @@ }, { "name": "symfony/debug", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", @@ -4255,7 +4264,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -4318,7 +4327,7 @@ }, { "name": "symfony/finder", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -4367,16 +4376,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "9a7469ec3e0225e7f0e14264bcd9e838e16186fe" + "reference": "a7b5fc605d1c215cea1122359044b1e682eb70c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9a7469ec3e0225e7f0e14264bcd9e838e16186fe", - "reference": "9a7469ec3e0225e7f0e14264bcd9e838e16186fe", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a7b5fc605d1c215cea1122359044b1e682eb70c0", + "reference": "a7b5fc605d1c215cea1122359044b1e682eb70c0", "shasum": "" }, "require": { @@ -4417,20 +4426,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2018-05-16T08:49:21+00:00" + "time": "2018-05-25T11:07:31+00:00" }, { "name": "symfony/http-kernel", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "66644bc7d17cc071d796efab9b950adbb86da134" + "reference": "3dac45df55ee0c5134c457a730cd68e2a2ce0445" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/66644bc7d17cc071d796efab9b950adbb86da134", - "reference": "66644bc7d17cc071d796efab9b950adbb86da134", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3dac45df55ee0c5134c457a730cd68e2a2ce0445", + "reference": "3dac45df55ee0c5134c457a730cd68e2a2ce0445", "shasum": "" }, "require": { @@ -4506,7 +4515,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2018-05-21T13:44:03+00:00" + "time": "2018-05-25T13:16:28+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4791,7 +4800,7 @@ }, { "name": "symfony/process", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -4840,7 +4849,7 @@ }, { "name": "symfony/routing", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", @@ -4918,7 +4927,7 @@ }, { "name": "symfony/translation", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", @@ -4986,7 +4995,7 @@ }, { "name": "symfony/var-dumper", - "version": "v3.4.10", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", diff --git a/database/seeds/Roles.php b/database/seeds/Roles.php index afbbebd4e..ebf664a3c 100644 --- a/database/seeds/Roles.php +++ b/database/seeds/Roles.php @@ -34,10 +34,10 @@ class Roles extends Seeder 'auth-roles' => 'c,r,u,d', 'auth-permissions' => 'c,r,u,d', 'auth-profile' => 'r,u', - 'companies-companies' => 'c,r,u,d', + 'common-companies' => 'c,r,u,d', 'common-import' => 'c', + 'common-items' => 'c,r,u,d', 'common-uploads' => 'd', - 'items-items' => 'c,r,u,d', 'incomes-invoices' => 'c,r,u,d', 'incomes-revenues' => 'c,r,u,d', 'incomes-customers' => 'c,r,u,d', @@ -68,9 +68,9 @@ class Roles extends Seeder 'manager' => [ 'admin-panel' => 'r', 'auth-profile' => 'r,u', - 'companies-companies' => 'c,r,u,d', + 'common-companies' => 'c,r,u,d', 'common-import' => 'c', - 'items-items' => 'c,r,u,d', + 'common-items' => 'c,r,u,d', 'incomes-invoices' => 'c,r,u,d', 'incomes-revenues' => 'c,r,u,d', 'incomes-customers' => 'c,r,u,d', diff --git a/database/seeds/TestCompany.php b/database/seeds/TestCompany.php index 6ca7bce79..88061a5fd 100644 --- a/database/seeds/TestCompany.php +++ b/database/seeds/TestCompany.php @@ -4,7 +4,7 @@ namespace Database\Seeds; use App\Models\Model; use App\Models\Auth\User; -use App\Models\Company\Company; +use App\Models\Common\Company; use Jenssegers\Date\Date; use Illuminate\Database\Seeder; use Setting; diff --git a/resources/views/companies/companies/create.blade.php b/resources/views/common/companies/create.blade.php similarity index 92% rename from resources/views/companies/companies/create.blade.php rename to resources/views/common/companies/create.blade.php index 0e1ffa80f..b31d404d5 100644 --- a/resources/views/companies/companies/create.blade.php +++ b/resources/views/common/companies/create.blade.php @@ -5,7 +5,7 @@ @section('content')
- {!! Form::open(['url' => 'companies/companies', 'files' => true, 'role' => 'form']) !!} + {!! Form::open(['url' => 'common/companies', 'files' => true, 'role' => 'form']) !!}
{{ Form::textGroup('company_name', trans('general.name'), 'id-card-o') }} @@ -24,7 +24,7 @@ diff --git a/resources/views/companies/companies/edit.blade.php b/resources/views/common/companies/edit.blade.php similarity index 95% rename from resources/views/companies/companies/edit.blade.php rename to resources/views/common/companies/edit.blade.php index a1ccf03d5..962cb4515 100644 --- a/resources/views/companies/companies/edit.blade.php +++ b/resources/views/common/companies/edit.blade.php @@ -7,7 +7,7 @@
{!! Form::model($company, [ 'method' => 'PATCH', - 'url' => ['companies/companies', $company->id], + 'url' => ['common/companies', $company->id], 'files' => true, 'role' => 'form' ]) !!} @@ -29,9 +29,9 @@
- @permission('update-companies-companies') + @permission('update-common-companies') @endpermission diff --git a/resources/views/companies/companies/index.blade.php b/resources/views/common/companies/index.blade.php similarity index 82% rename from resources/views/companies/companies/index.blade.php rename to resources/views/common/companies/index.blade.php index e18a65b10..1429c92ae 100644 --- a/resources/views/companies/companies/index.blade.php +++ b/resources/views/common/companies/index.blade.php @@ -2,9 +2,9 @@ @section('title', trans_choice('general.companies', 2)) -@permission('create-companies-companies') +@permission('create-common-companies') @section('new_button') -  {{ trans('general.add_new') }} +  {{ trans('general.add_new') }} @endsection @endpermission @@ -13,7 +13,7 @@
- {!! Form::open(['url' => 'companies/companies', 'role' => 'form', 'method' => 'GET']) !!} + {!! Form::open(['url' => 'common/companies', 'role' => 'form', 'method' => 'GET']) !!}
{!! Form::text('search', request('search'), ['class' => 'form-control input-filter input-sm', 'placeholder' => trans('general.search_placeholder')]) !!} @@ -45,7 +45,7 @@ @foreach($companies as $item) {{ $item->id }} - {{ $item->company_name }} + {{ $item->company_name }} {{ $item->domain }} {{ $item->company_email }} {{ Date::parse($item->created_at)->format($date_format) }} @@ -63,11 +63,11 @@
diff --git a/resources/views/dashboard/dashboard/index.blade.php b/resources/views/common/dashboard/index.blade.php similarity index 98% rename from resources/views/dashboard/dashboard/index.blade.php rename to resources/views/common/dashboard/index.blade.php index 097bfe03d..749692874 100644 --- a/resources/views/dashboard/dashboard/index.blade.php +++ b/resources/views/common/dashboard/index.blade.php @@ -267,7 +267,7 @@ var period = $('#period').val(); $.ajax({ - url: '{{ url("dashboard/dashboard/cashflow") }}', + url: '{{ url("common/dashboard/cashflow") }}', type: 'get', dataType: 'html', data: 'period=' + period + '&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD'), @@ -283,7 +283,7 @@ $('#period').val('month'); $.ajax({ - url: '{{ url("dashboard/dashboard/cashflow") }}', + url: '{{ url("common/dashboard/cashflow") }}', type: 'get', dataType: 'html', data: 'period=month&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD'), @@ -299,7 +299,7 @@ $('#period').val('quarter'); $.ajax({ - url: '{{ url("dashboard/dashboard/cashflow") }}', + url: '{{ url("common/dashboard/cashflow") }}', type: 'get', dataType: 'html', data: 'period=quarter&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD'), diff --git a/resources/views/items/items/create.blade.php b/resources/views/common/items/create.blade.php similarity index 98% rename from resources/views/items/items/create.blade.php rename to resources/views/common/items/create.blade.php index b4bd4af29..42a238557 100644 --- a/resources/views/items/items/create.blade.php +++ b/resources/views/common/items/create.blade.php @@ -5,7 +5,7 @@ @section('content')
- {!! Form::open(['url' => 'items/items', 'files' => true, 'role' => 'form']) !!} + {!! Form::open(['url' => 'common/items', 'files' => true, 'role' => 'form']) !!}
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }} @@ -41,7 +41,7 @@ diff --git a/resources/views/items/items/edit.blade.php b/resources/views/common/items/edit.blade.php similarity index 96% rename from resources/views/items/items/edit.blade.php rename to resources/views/common/items/edit.blade.php index 555b74e36..eefaf318e 100644 --- a/resources/views/items/items/edit.blade.php +++ b/resources/views/common/items/edit.blade.php @@ -8,7 +8,7 @@ {!! Form::model($item, [ 'method' => 'PATCH', 'files' => true, - 'url' => ['items/items', $item->id], + 'url' => ['common/items', $item->id], 'role' => 'form' ]) !!} @@ -35,9 +35,9 @@
- @permission('update-items-items') + @permission('update-common-items') @endpermission diff --git a/resources/views/items/items/index.blade.php b/resources/views/common/items/index.blade.php similarity index 82% rename from resources/views/items/items/index.blade.php rename to resources/views/common/items/index.blade.php index 59ff6cfe5..07242a725 100644 --- a/resources/views/items/items/index.blade.php +++ b/resources/views/common/items/index.blade.php @@ -2,10 +2,10 @@ @section('title', trans_choice('general.items', 2)) -@permission('create-items-items') +@permission('create-common-items') @section('new_button') -  {{ trans('general.add_new') }} -  {{ trans('import.import') }} +  {{ trans('general.add_new') }} +  {{ trans('import.import') }} @endsection @endpermission @@ -13,7 +13,7 @@
- {!! Form::open(['url' => 'items/items', 'role' => 'form', 'method' => 'GET']) !!} + {!! Form::open(['url' => 'common/items', 'role' => 'form', 'method' => 'GET']) !!}
{!! Form::text('search', request('search'), ['class' => 'form-control input-filter input-sm', 'placeholder' => trans('general.search_placeholder')]) !!} @@ -47,7 +47,7 @@ @foreach($items as $item) {{ $item->name }} - {{ $item->name }} + {{ $item->name }} {{ $item->category ? $item->category->name : trans('general.na') }} {{ $item->quantity }} {{ money($item->sale_price, setting('general.default_currency'), true) }} @@ -65,14 +65,14 @@
diff --git a/resources/views/expenses/bills/create.blade.php b/resources/views/expenses/bills/create.blade.php index 97eeaa61d..f960bdb24 100644 --- a/resources/views/expenses/bills/create.blade.php +++ b/resources/views/expenses/bills/create.blade.php @@ -220,7 +220,7 @@ placeholder : '{{ trans('general.form.no_file_selected') }}' }); - var autocomplete_path = "{{ url('items/items/autocomplete') }}"; + var autocomplete_path = "{{ url('common/items/autocomplete') }}"; $(document).on('click', '.form-control.typeahead', function() { input_id = $(this).attr('id').split('-'); @@ -336,7 +336,7 @@ function totalItem() { $.ajax({ - url: '{{ url("items/items/totalItem") }}', + url: '{{ url("common/items/totalItem") }}', type: 'POST', dataType: 'JSON', data: $('#currency_code, #discount input[type=\'number\'], #items input[type=\'text\'],#items input[type=\'number\'],#items input[type=\'hidden\'], #items textarea, #items select'), diff --git a/resources/views/expenses/bills/edit.blade.php b/resources/views/expenses/bills/edit.blade.php index 0006f1adf..07a53064e 100644 --- a/resources/views/expenses/bills/edit.blade.php +++ b/resources/views/expenses/bills/edit.blade.php @@ -253,7 +253,7 @@ }); @endif - var autocomplete_path = "{{ url('items/items/autocomplete') }}"; + var autocomplete_path = "{{ url('common/items/autocomplete') }}"; $(document).on('click', '.form-control.typeahead', function() { input_id = $(this).attr('id').split('-'); @@ -369,7 +369,7 @@ function totalItem() { $.ajax({ - url: '{{ url("items/items/totalItem") }}', + url: '{{ url("common/items/totalItem") }}', type: 'POST', dataType: 'JSON', data: $('#currency_code, #discount input[type=\'number\'], #items input[type=\'text\'],#items input[type=\'number\'],#items input[type=\'hidden\'], #items textarea, #items select'), diff --git a/resources/views/incomes/invoices/create.blade.php b/resources/views/incomes/invoices/create.blade.php index 56abf72b0..f055a7266 100644 --- a/resources/views/incomes/invoices/create.blade.php +++ b/resources/views/incomes/invoices/create.blade.php @@ -221,7 +221,7 @@ placeholder : '{{ trans('general.form.no_file_selected') }}' }); - var autocomplete_path = "{{ url('items/items/autocomplete') }}"; + var autocomplete_path = "{{ url('common/items/autocomplete') }}"; $(document).on('click', '.form-control.typeahead', function() { input_id = $(this).attr('id').split('-'); @@ -337,7 +337,7 @@ function totalItem() { $.ajax({ - url: '{{ url("items/items/totalItem") }}', + url: '{{ url("common/items/totalItem") }}', type: 'POST', dataType: 'JSON', data: $('#currency_code, #discount input[type=\'number\'], #items input[type=\'text\'],#items input[type=\'number\'],#items input[type=\'hidden\'], #items textarea, #items select'), diff --git a/resources/views/incomes/invoices/edit.blade.php b/resources/views/incomes/invoices/edit.blade.php index e80a75f35..3e183a006 100644 --- a/resources/views/incomes/invoices/edit.blade.php +++ b/resources/views/incomes/invoices/edit.blade.php @@ -252,7 +252,7 @@ }); @endif - var autocomplete_path = "{{ url('items/items/autocomplete') }}"; + var autocomplete_path = "{{ url('common/items/autocomplete') }}"; $(document).on('click', '.form-control.typeahead', function() { input_id = $(this).attr('id').split('-'); @@ -368,7 +368,7 @@ function totalItem() { $.ajax({ - url: '{{ url("items/items/totalItem") }}', + url: '{{ url("common/items/totalItem") }}', type: 'POST', dataType: 'JSON', data: $('#currency_code, #discount input[type=\'number\'], #items input[type=\'text\'],#items input[type=\'number\'],#items input[type=\'hidden\'], #items textarea, #items select'), diff --git a/resources/views/partials/admin/head.blade.php b/resources/views/partials/admin/head.blade.php index 9976e3aa9..27b7ca007 100644 --- a/resources/views/partials/admin/head.blade.php +++ b/resources/views/partials/admin/head.blade.php @@ -57,7 +57,7 @@ @stack('js') diff --git a/resources/views/partials/admin/menu.blade.php b/resources/views/partials/admin/menu.blade.php index f97149f7d..8a03d0f8b 100644 --- a/resources/views/partials/admin/menu.blade.php +++ b/resources/views/partials/admin/menu.blade.php @@ -8,15 +8,15 @@

{{ str_limit(setting('general.company_name'), 22) }}

- @permission('read-companies-companies') + @permission('read-common-companies') @endpermission diff --git a/resources/views/partials/customer/head.blade.php b/resources/views/partials/customer/head.blade.php index dc64f5fa3..c2d6769f8 100644 --- a/resources/views/partials/customer/head.blade.php +++ b/resources/views/partials/customer/head.blade.php @@ -62,7 +62,7 @@ @stack('js') diff --git a/resources/views/partials/modules/head.blade.php b/resources/views/partials/modules/head.blade.php index 50132aae8..f83c9ddea 100644 --- a/resources/views/partials/modules/head.blade.php +++ b/resources/views/partials/modules/head.blade.php @@ -58,7 +58,7 @@