[WIP] Fix ergonomics rules
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use App\User;
|
||||
use App\Models\Core\Auth\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Categories;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Category $category
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Category $category)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Category $category
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Category $category)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Category $category
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Category $category)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Category $category
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Category $category)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Shop\Admin;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Users;
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
@@ -27,7 +27,6 @@ class DashboardController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$data = [];
|
||||
$dashboard = 'dashboard_general';
|
||||
|
||||
if (Users::hasRole('admin')) {
|
||||
$dashboard = 'dashboard';
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use App\Section;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\Sections;
|
||||
|
||||
class SectionController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -13,9 +14,19 @@ class SectionController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
//
|
||||
if ($request->ajax()) {
|
||||
return self::getDatatable($request);
|
||||
} else {
|
||||
$data = [];
|
||||
return view('Shop.Admin.Sections.list', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return Sections::getTables($request->all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,7 +36,8 @@ class SectionController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
$data = [];
|
||||
return view('Shop.Admin.Sections.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,39 +48,42 @@ class SectionController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$ret = Sections::store($request);
|
||||
return redirect()->route('Shop.Admin.Sections.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Section $Section
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Section $Section)
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
$data = Sections::get($id);
|
||||
return view('Shop.Admin.Sections.view', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Section $Section
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Section $Section)
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
$data = Sections::get($id);
|
||||
return view('Shop.Admin.Sections.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Section $Section
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Section $Section)
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -76,11 +91,11 @@ class SectionController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Section $Section
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Section $Section)
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
return Sections::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,30 +14,19 @@ class SectionController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
//
|
||||
if ($request->ajax()) {
|
||||
return self::getDatatable($request);
|
||||
} else {
|
||||
$data = [];
|
||||
return view('Shop.Sections.list', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
return Sections::getTables($request->all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,40 +37,8 @@ class SectionController extends Controller
|
||||
*/
|
||||
public function show(Customer $customer)
|
||||
{
|
||||
//
|
||||
$data = Sections::get($id);
|
||||
return view('Shop.Admin.Sections.view', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,18 @@ class Shop
|
||||
$menu->add('Commerce', [ 'permission' => 'backend', 'icon' => 'cog' ])
|
||||
->id('shop')
|
||||
->activeIfRoute('shop')
|
||||
|
||||
->order(1);
|
||||
|
||||
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Orders.index'])->order(1);
|
||||
$menu->addTo('shop', 'Factures', [ 'route' => 'Shop.Admin.Invoices.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Invoices.index'])->order(2);
|
||||
|
||||
$menu->addTo('shop', 'Categories', [ 'route' => 'Shop.Admin.Products.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Products.index'])->order(3);
|
||||
$menu->addTo('shop', 'Categories', [ 'route' => 'Shop.Admin.Sections.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Sections.index'])->order(1);
|
||||
$menu->addTo('shop', 'Produits', [ 'route' => 'Shop.Admin.Products.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Products.index'])->order(4);
|
||||
->activeIfRoute(['Shop.Admin.Products.index'])->order(2);
|
||||
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Orders.index'])->order(3);
|
||||
$menu->addTo('shop', 'Factures', [ 'route' => 'Shop.Admin.Invoices.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Invoices.index'])->order(4);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -12,12 +12,12 @@ class Application extends Model
|
||||
|
||||
public function pages()
|
||||
{
|
||||
return $this->hasMany('App\Models\Modules\ApplicationPage');
|
||||
return $this->hasMany('App\Models\Core\App\ApplicationPage');
|
||||
}
|
||||
|
||||
public function modules()
|
||||
{
|
||||
return $this->hasMany('App\Models\Modules\ApplicationModule');
|
||||
return $this->hasMany('App\Models\Core\App\ApplicationModule');
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -12,7 +13,7 @@ class ApplicationModule extends Model
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Modules\Application');
|
||||
return $this->belongsTo('App\Models\Core\App\Application');
|
||||
}
|
||||
|
||||
public function permissions()
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Application;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -12,7 +12,7 @@ class ApplicationPage extends Model
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Modules\Application');
|
||||
return $this->belongsTo('App\Models\Core\App');
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Laratrust\Models\LaratrustPermission;
|
||||
|
||||
@@ -29,12 +29,12 @@ class Permission extends LaratrustPermission
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Application');
|
||||
return $this->belongsTo('App\Models\Core\App\Application');
|
||||
}
|
||||
|
||||
public function application_module()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ApplicationModule');
|
||||
return $this->belongsTo('App\Models\Core\App\ApplicationModule');
|
||||
}
|
||||
|
||||
public function getDisplayNameAttribute($value)
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -10,12 +10,12 @@ class PermissionRole extends Model
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo('App\Permission');
|
||||
return $this->belongsTo('App\Models\Core\Auth\Permission');
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo('App\Role');
|
||||
return $this->belongsTo('App\Models\Core\Auth\Role');
|
||||
}
|
||||
|
||||
public function scopeByPermission($query, $id)
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -10,17 +10,17 @@ class PermissionUser extends Model
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo('App\Permission');
|
||||
return $this->belongsTo('App\Models\Core\Auth\Permission');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo('App\Team');
|
||||
return $this->belongsTo('App\Models\Core\Auth\Team');
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Laratrust\Models\LaratrustRole;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -11,12 +11,12 @@ class RoleUser extends Model
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo('App\Team');
|
||||
return $this->belongsTo('App\Models\Core\Auth\Team');
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -15,12 +15,7 @@ class Team extends LaratrustTeam
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany('App\User');
|
||||
}
|
||||
|
||||
public function society()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Society');
|
||||
return $this->hasMany('App\Models\Core\Auth\User');
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
@@ -28,8 +23,4 @@ class Team extends LaratrustTeam
|
||||
return $query->where('active', 1);
|
||||
}
|
||||
|
||||
public function scopeBySociety($query, $id)
|
||||
{
|
||||
return $query->where('society_id', $id);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -11,12 +11,12 @@ class TeamUser extends Model
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo('App\Team');
|
||||
return $this->belongsTo('App\Models\Core\Auth\Team');
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Mpociot\Teamwork\Traits\UserHasTeams;
|
||||
use Sebastienheyd\Boilerplate\Notifications\NewUser as NewUserNotification;
|
||||
@@ -55,6 +56,7 @@ class User extends Authenticatable
|
||||
use LaratrustUserTrait;
|
||||
use SoftDeletes;
|
||||
use UserHasTeams;
|
||||
use AuthenticationLogable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -75,40 +77,21 @@ class User extends Authenticatable
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function user_detail()
|
||||
public function teams()
|
||||
{
|
||||
return $this->hasOne('App\Models\UserDetail');
|
||||
}
|
||||
|
||||
public function teams2()
|
||||
{
|
||||
return $this->hasManyThrough('App\Team', 'App\Models\TeamUser', 'user_id', 'id', 'id', 'team_id');
|
||||
return $this->hasManyThrough('App\Models\Core\Auth\Team', 'App\Models\Core\Auth\TeamUser', 'user_id', 'id', 'id', 'team_id');
|
||||
}
|
||||
|
||||
public function scopeByTeam($query, $id)
|
||||
{
|
||||
return $query->whereHas('teams2', function ($query) use ($id) {
|
||||
return $query->whereHas('teams', function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByUniqueTeam($query)
|
||||
{
|
||||
return $query->has('teams2', '=', 1);
|
||||
}
|
||||
|
||||
public function scopeBySociete($query, $id)
|
||||
{
|
||||
return $query->whereHas('teams2', function ($query) use ($id) {
|
||||
$query->bySociete($id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByPartenaire($query, $id)
|
||||
{
|
||||
return $query->whereHas('teams2', function ($query) use ($id) {
|
||||
$query->byPartenaire($id);
|
||||
});
|
||||
return $query->has('teams', '=', 1);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
@@ -8,25 +8,16 @@ class Customer extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function Invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Invoice');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function Orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Order');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function User()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
|
||||
21
app/Models/Shop/CustomerAddress.php
Normal file
21
app/Models/Shop/CustomerAddress.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerAddress extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function Customer()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Customer');
|
||||
}
|
||||
|
||||
public function Orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Order');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,19 +8,19 @@ class ProductPrice extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function ProductAttribute()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ProductAttribute');
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $id)
|
||||
{
|
||||
return $query->where('product_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Models/Shop/ProductSection.php
Normal file
30
app/Models/Shop/ProductSection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductSection extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function Product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
}
|
||||
|
||||
public function Section()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $id)
|
||||
{
|
||||
return $query->where('product_id', $id);
|
||||
}
|
||||
|
||||
public function scopeBySection($query, $id)
|
||||
{
|
||||
return $query->where('section_id', $id);
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,13 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Rinvex\Categories\Traits\Categorizable,
|
||||
|
||||
class Section extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
use Categorizable;
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function Products()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Product');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\ApplicationPage;
|
||||
use App\Models\Core\App\ApplicationPage;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
namespace App\Repositories\Core\App;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
85
app/Repositories/Core/Auth/Permissions.php
Normal file
85
app/Repositories/Core/Auth/Permissions.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Core\Auth\Permission;
|
||||
|
||||
class Permissions
|
||||
{
|
||||
public static function getModules()
|
||||
{
|
||||
return Permission::select('module')->distinct('module')->get()->pluck('module');
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Permission::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getInfo($id)
|
||||
{
|
||||
return Permission::find($id);
|
||||
}
|
||||
|
||||
public static function select_all()
|
||||
{
|
||||
return self::getAll()->toArray();
|
||||
}
|
||||
|
||||
public static function select_by_id($id)
|
||||
{
|
||||
return Permission::find($id)->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Permission::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Permission::where('name', $name)->first();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Permission::find($id);
|
||||
}
|
||||
|
||||
public static function getTable($id)
|
||||
{
|
||||
$datas = Permission::withCount(['users']);
|
||||
return Datatables::of($datas)->make(true);
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
Users::destroyByUniquePermission($id);
|
||||
return Permission::destroy($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return (isset($data['id']) && $data['id']) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Permission::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Permission::find($data['id'])->update($data);
|
||||
}
|
||||
|
||||
public static function count()
|
||||
{
|
||||
return Permission::count();
|
||||
}
|
||||
}
|
||||
147
app/Repositories/Core/Auth/Roles.php
Normal file
147
app/Repositories/Core/Auth/Roles.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Core\Auth\Role;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
|
||||
class Roles
|
||||
{
|
||||
use LaratrustUserTrait;
|
||||
|
||||
public static function store($input)
|
||||
{
|
||||
if (isset($input['id']) && $input['id']) {
|
||||
return self::update($input);
|
||||
} else {
|
||||
return self::insert($input);
|
||||
}
|
||||
}
|
||||
|
||||
// ajoute une forme juridique
|
||||
public static function insert($input)
|
||||
{
|
||||
$permissions = array_keys($input['permissions']);
|
||||
$name = $input['name'];
|
||||
$translated = $input['translated'];
|
||||
self::setTranslation($name, $translated);
|
||||
$role = Role::create(['name' => $name, 'display_name' => $name, 'translated' => $translated, 'description' => '', 'active' => true]);
|
||||
$role->attachPermissions($permissions);
|
||||
return $role;
|
||||
}
|
||||
|
||||
// met à jour les informations d'une forme juridique
|
||||
public static function update($input, $id = false)
|
||||
{
|
||||
$id = ($id) ? $id : $input['id'];
|
||||
$permissions = array_keys($input['permissions']);
|
||||
$name = $input['name'];
|
||||
$translated = $input['translated'];
|
||||
self::setTranslation($name, $translated);
|
||||
$role = Role::find($id);
|
||||
$role->update(['name' => $name, 'translated' => $translated]);
|
||||
$role->syncPermissions($permissions);
|
||||
return $role;
|
||||
}
|
||||
|
||||
// supprime une forme juridique
|
||||
public static function delete($id)
|
||||
{
|
||||
$old = self::select_by_id($id);
|
||||
self::deleteTranslation($old->translated);
|
||||
return Role::destroy($id);
|
||||
}
|
||||
|
||||
// met à jour le statut actif/inactif d'une forme juridique
|
||||
public static function toggle_active($id, $active)
|
||||
{
|
||||
return Role::find($id)->update(['active' => $active]);
|
||||
}
|
||||
|
||||
// compte le nombre de formes juridiques
|
||||
public static function count()
|
||||
{
|
||||
return Role::count();
|
||||
}
|
||||
|
||||
// récupère toutes les infos sur les formes juridiques
|
||||
public static function select_all()
|
||||
{
|
||||
return Role::all()->toArray();
|
||||
}
|
||||
|
||||
public static function select_by_id($id)
|
||||
{
|
||||
return Role::find($id)->toArray();
|
||||
}
|
||||
|
||||
public static function getWithPermissions($id)
|
||||
{
|
||||
$role = Role::find($id)->toArray();
|
||||
$role['permissions'] = Role::find($id)->permissions->pluck('id')->toArray();
|
||||
return $role;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Role::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Role::where('name', $name)->first();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Role::find($id);
|
||||
}
|
||||
|
||||
public static function getTable($id)
|
||||
{
|
||||
$datas = Role::orderBy('name', 'asc');
|
||||
return Datatables::of($datas)->make(true);
|
||||
}
|
||||
|
||||
public static function getRolesByUser($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : Users::getId();
|
||||
return RoleUser::byUser($user_id);
|
||||
}
|
||||
|
||||
public static function getUsersByRole($id)
|
||||
{
|
||||
return RoleUser::byTeam($id)->get();
|
||||
}
|
||||
|
||||
public static function getUsersIdByRole($id)
|
||||
{
|
||||
return self::getUsersByRole($id)->pluck('user_id');
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Role::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function setTranslation($name, $translated)
|
||||
{
|
||||
$lang = Translate::getLang();
|
||||
$appli = 1; // ContractDrive
|
||||
$client = 1; // Client
|
||||
Translations::setTranslation($name, $translated, $lang, $appli, $client);
|
||||
}
|
||||
|
||||
public static function deleteTranslation($translated)
|
||||
{
|
||||
$lang = Translate::getLang();
|
||||
$appli = 1; // ContractDrive
|
||||
$client = 1; // Client
|
||||
Translations::deleteTranslation($translated, $lang, $appli, $client);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
namespace App\Repositories;
|
||||
namespace App\Repositories\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\Datatables\Datatables;
|
||||
|
||||
use App\Team;
|
||||
use App\Models\TeamUser;
|
||||
use App\Models\Core\Auth\Team;
|
||||
use App\Models\Core\Auth\TeamUser;
|
||||
|
||||
use App\Repositories\Users;
|
||||
use App\Repositories\Core\User\Users;
|
||||
|
||||
class Teams
|
||||
{
|
||||
@@ -1,15 +1,14 @@
|
||||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
|
||||
use App\User;
|
||||
use App\Models\RoleUser;
|
||||
use App\Models\Societe;
|
||||
use App\Models\Hestimmo\Partenaire;
|
||||
use App\Models\Core\Auth\User;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
|
||||
class Users
|
||||
{
|
||||
@@ -20,46 +19,6 @@ class Users
|
||||
return (self::hasRole('admin')) ? true : false;
|
||||
}
|
||||
|
||||
public static function isPartenaire()
|
||||
{
|
||||
return (self::hasRole('partenaire')) ? self::getPartenaireId() : false;
|
||||
}
|
||||
|
||||
public static function isPromoteur()
|
||||
{
|
||||
return (self::hasRole('promoteur')) ? self::getPromoteurId() : false;
|
||||
}
|
||||
|
||||
public static function isCommercial()
|
||||
{
|
||||
return (self::hasRole('commercial')) ? true : false;
|
||||
}
|
||||
|
||||
public static function getPartenaireId($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : self::getId();
|
||||
$partenaire = Partenaire::byUser($user_id)->first();
|
||||
return $partenaire ? $partenaire->id : null;
|
||||
}
|
||||
|
||||
public static function getPartenaire($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : self::getId();
|
||||
return Societe::partenaireByUser($user_id)->first();
|
||||
}
|
||||
|
||||
public static function getPromoteurId($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : self::getId();
|
||||
return Promoteur::byUser($user_id)->first()->id;
|
||||
}
|
||||
|
||||
public static function getPromoteur($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : self::getId();
|
||||
return Societe::promoteurByUser($user_id)->first();
|
||||
}
|
||||
|
||||
public static function getInfo($id = false)
|
||||
{
|
||||
return self::getWithDetail($id);
|
||||
Reference in New Issue
Block a user