diff --git a/app/Datatables/FamiliesDataTable.php b/app/Datatables/FamiliesDataTable.php new file mode 100644 index 00000000..5e2b32fa --- /dev/null +++ b/app/Datatables/FamiliesDataTable.php @@ -0,0 +1,89 @@ +eloquent($query) + ->addColumn('action', ''); + } + + /** + * Get query source of dataTable. + * + * @param \App\Family $model + * @return \Illuminate\Database\Eloquent\Builder + */ + public function query(Family $model) + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use html builder. + * + * @return \Yajra\DataTables\Html\Builder + */ + public function html() + { + return $this->builder() + ->setTableId('families-table') + ->columns($this->getColumns()) + ->minifiedAjax() + ->dom('Bfrtip') + ->orderBy(1) + ->buttons( + Button::make('create'), + Button::make('export'), + Button::make('print'), + Button::make('reset'), + Button::make('reload') + ); + } + + /** + * Get columns. + * + * @return array + */ + protected function getColumns() + { + return [ + Column::make('name'), + Column::make('alias'), + Column::make('latin'), + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + ]; + } + + /** + * Get filename for export. + * + * @return string + */ + protected function filename() + { + return 'Families_' . date('YmdHis'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php new file mode 100644 index 00000000..8586dcb7 --- /dev/null +++ b/app/Http/Controllers/Admin/HomeController.php @@ -0,0 +1,29 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index() + { + // return redirect('dashboard'); + } +} diff --git a/app/Http/Controllers/Shop/Admin/FamilyController.php b/app/Http/Controllers/Shop/Admin/FamilyController.php new file mode 100644 index 00000000..71a0356f --- /dev/null +++ b/app/Http/Controllers/Shop/Admin/FamilyController.php @@ -0,0 +1,52 @@ +render('Shop.Admin.Families.list'); + } + + public function getDatatable(Request $request) + { + return Families::getTables($request->all()); + } + + public function create() + { + $data = []; + return view('Shop.Admin.Families.create', $data); + } + + public function store(Request $request) + { + $ret = Families::store($request); + return redirect()->route('Shop.Admin.Families.index'); + } + + public function show($id) + { + $data = Families::get($id); + return view('Shop.Admin.Families.view', $data); + } + + public function edit($id) + { + $data = Families::get($id); + return view('Shop.Admin.Families.edit', $data); + } + + public function destroy($id) + { + return Families::destroy($id); + } +} diff --git a/app/Http/Controllers/Shop/Admin/GenreController.php b/app/Http/Controllers/Shop/Admin/GenreController.php new file mode 100644 index 00000000..900b36ac --- /dev/null +++ b/app/Http/Controllers/Shop/Admin/GenreController.php @@ -0,0 +1,55 @@ +ajax()) { + return self::getDatatable($request); + } else { + $data = []; + return view('Admin.Shop.Genres.list', $data); + } + } + + public function getDatatable(Request $request) + { + return Genres::getTables($request->all()); + } + + public function create() + { + $data = []; + return view('Admin.Shop.Genres.create', $data); + } + + public function store(Request $request) + { + $ret = Genres::store($request); + return redirect()->route('Admin.Shop.Genres.index'); + } + + public function show($id) + { + $data = Genres::get($id); + return view('Admin.Shop.Genres.view', $data); + } + + public function edit($id) + { + $data = Genres::get($id); + return view('Admin.Shop.Genres.edit', $data); + } + + public function destroy($id) + { + return Genres::destroy($id); + } +} diff --git a/app/Http/Controllers/Shop/Admin/SpecieController.php b/app/Http/Controllers/Shop/Admin/SpecieController.php new file mode 100644 index 00000000..1ea31642 --- /dev/null +++ b/app/Http/Controllers/Shop/Admin/SpecieController.php @@ -0,0 +1,101 @@ +ajax()) { + return self::getDatatable($request); + } else { + $data = []; + return view('Shop.Admin.Species.list', $data); + } + } + + public function getDatatable(Request $request) + { + return Species::getDatatable($request->all()); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $data = []; + return view('Shop.Admin.Species.create', $data); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $ret = Species::store($request); + return redirect()->route('Shop.Admin.Species.index'); + } + + /** + * Display the specified resource. + * + * @param \App\Customer $customer + * @return \Illuminate\Http\Response + */ + public function show($id) + { + $data = Species::get($id); + return view('Shop.Admin.Species.view', $data); + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Customer $customer + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $data = Species::get($id); + return view('Shop.Admin.Species.edit', $data); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Customer $customer + * @return \Illuminate\Http\Response + */ + public function update(Request $request) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Customer $customer + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + return Species::destroy($id); + } +} diff --git a/app/Menu/Shop.php b/app/Menu/Shop.php index 490a6668..ac8f0c9d 100644 --- a/app/Menu/Shop.php +++ b/app/Menu/Shop.php @@ -9,20 +9,26 @@ class Shop { public function make(Builder $menu) { - $menu->add('Commerce', [ 'permission' => 'backend', 'icon' => 'cog' ]) + $menu->add('Commerce', [ 'permission' => 'backend', 'icon' => 'shopping-basket' ]) ->id('shop') ->activeIfRoute('shop') - ->order(1); + $menu->addTo('shop', 'Familles', [ 'route' => 'Shop.Admin.Families.index', 'permission' => 'backend' ]) + ->activeIfRoute(['Shop.Admin.Families.index'])->order(1); + $menu->addTo('shop', 'Genres', [ 'route' => 'Shop.Admin.Genres.index', 'permission' => 'backend' ]) + ->activeIfRoute(['Shop.Admin.Genres.index'])->order(2); + $menu->addTo('shop', 'Espèces', [ 'route' => 'Shop.Admin.Species.index', 'permission' => 'backend' ]) + ->activeIfRoute(['Shop.Admin.Species.index'])->order(3); + $menu->addTo('shop', 'Categories', [ 'route' => 'Shop.Admin.Sections.index', 'permission' => 'backend' ]) - ->activeIfRoute(['Shop.Admin.Sections.index'])->order(1); + ->activeIfRoute(['Shop.Admin.Sections.index'])->order(4); $menu->addTo('shop', 'Produits', [ 'route' => 'Shop.Admin.Products.index', 'permission' => 'backend' ]) - ->activeIfRoute(['Shop.Admin.Products.index'])->order(2); + ->activeIfRoute(['Shop.Admin.Products.index'])->order(5); $menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend' ]) - ->activeIfRoute(['Shop.Admin.Orders.index'])->order(3); + ->activeIfRoute(['Shop.Admin.Orders.index'])->order(6); $menu->addTo('shop', 'Factures', [ 'route' => 'Shop.Admin.Invoices.index', 'permission' => 'backend' ]) - ->activeIfRoute(['Shop.Admin.Invoices.index'])->order(4); + ->activeIfRoute(['Shop.Admin.Invoices.index'])->order(7); diff --git a/app/Models/Modules/Family.php b/app/Models/Modules/Family.php deleted file mode 100644 index 44d86d38..00000000 --- a/app/Models/Modules/Family.php +++ /dev/null @@ -1,11 +0,0 @@ -hasMany('App\Models\Shop\Genre'); + } +} \ No newline at end of file diff --git a/app/Models/Shop/Genre.php b/app/Models/Shop/Genre.php new file mode 100644 index 00000000..1b379252 --- /dev/null +++ b/app/Models/Shop/Genre.php @@ -0,0 +1,17 @@ +belongsTo('App\Models\Shop\Family'); + } + +} \ No newline at end of file diff --git a/app/Models/Shop/Specie.php b/app/Models/Shop/Specie.php new file mode 100644 index 00000000..083a0071 --- /dev/null +++ b/app/Models/Shop/Specie.php @@ -0,0 +1,16 @@ +belongsTo('App\Models\Shop\Family'); + } +} \ No newline at end of file diff --git a/app/Repositories/Families.php b/app/Repositories/Families.php new file mode 100644 index 00000000..ce7dd259 --- /dev/null +++ b/app/Repositories/Families.php @@ -0,0 +1,54 @@ +make(true); + } + + public static function getAll() + { + return Family::orderBy('name','asc')->get(); + } + + public static function get($id) + { + return Family::find($id); + } + + public static function store($data) + { + $id = isset($data['id']) ? $data['id'] : false; + $item = $id ? self::update($data) : self::create($data); + return $item->id; + } + + public static function create($data) + { + return Family::create($data); + } + + public static function update($data) + { + return Family::find($id)->update($data); + } + + public static function destroy($id) + { + return Family::destroy($id); + } + +} diff --git a/app/Repositories/Genres.php b/app/Repositories/Genres.php new file mode 100644 index 00000000..d03ffa36 --- /dev/null +++ b/app/Repositories/Genres.php @@ -0,0 +1,54 @@ +make(true); + } + + public static function getAll() + { + return Genre::orderBy('name','asc')->get(); + } + + public static function get($id) + { + return Genre::find($id); + } + + public static function store($data) + { + $id = isset($data['id']) ? $data['id'] : false; + $item = $id ? self::update($data) : self::create($data); + return $item->id; + } + + public static function create($data) + { + return Genre::create($data); + } + + public static function update($data) + { + return Genre::find($id)->update($data); + } + + public static function destroy($id) + { + return Genre::destroy($id); + } + +} diff --git a/app/Repositories/Shop/Products.php b/app/Repositories/Shop/Products.php index 5dbbe2f7..0a288f46 100644 --- a/app/Repositories/Shop/Products.php +++ b/app/Repositories/Shop/Products.php @@ -1,6 +1,6 @@ orderBy('name'); + $model = Product::orderBy('name'); return Datatables::of($model)->make(true); } - public static function select_all() + public static function getAll() { - return Product::select('id','name','active')->orderBy('name','asc')->get()->toArray(); + return Product::orderBy('name','asc')->get(); } - public static function select_by_id($id) + public static function get($id) { - return Product::find($id)->toArray(); - } - - public static function getId($Product = false) - { - $Product = self::get($Product); - return $Product ? $Product->id : false; - } - - public static function get($Product = false) - { - $website = self::getWebsite($Product); - return $website ? Product::byWebsite($website->id)->first() : false; + return Product::find($id); } public static function store($data) { $id = isset($data['id']) ? $data['id'] : false; - if (!$id) { - $Product_id = self::create($data); - } else { - $Product_id = self::update($data); - } - - ApplicationProducts::associate($Product_id, $data['applications']); - - return $Product_id; + $item = $id ? self::update($data) : self::create($data); + return $item->id; } public static function create($data) { - $slug = Str::slug($data['slug'],'-'); - $url = $slug . '.' . Partners::getDomain(); - $website = Websites::create($url); - $item = []; - $item['website_id'] = $website->id; - $item['name'] = $data['name']; - $item['slug'] = $slug; - $item['repository'] = $slug; - $item['session_name'] = $slug . '_sess'; - $item['logo_image'] = 'logo.png'; - $item['background_image'] = 'login-background.jpg'; - $item['custom_css'] = 'Product.css'; - $item['active'] = true; - $Product = Product::create($item); - - $DB_system = Partners::getDBName(); - $sql = "GRANT SELECT ON `$DB_system`.* TO '" . $website->uuid . "'@localhost"; - DB::connection('system')->statement($sql); - // GRANT SELECT ON `legstack`.* TO '828656d3463e45c0a33e9cc8b5c2f265'@'127.0.0.1'; - return $Product->id; + return Product::create($data); } public static function update($data) { - // TODO + return Product::find($id)->update($data); } public static function destroy($id) { - $Product = Product::find($id); - + return Product::destroy($id); } - public static function getPublicPath($repository = false, $Product = false) - { - return self::getLocalPath() . self::getPath($repository, $Product); - } - - /** - * [getPrivatePath renvoie le chemin complet du repertoire du tenant ] - * @param boolean $repository [description] - * @param boolean $Product [description] - * @return [type] [description] - */ - public static function getPrivatePath($repository = false, $Product = false) - { - return self::getPrivateDir($repository, $Product); - } - - public static function getPrivateDir($repository = false, $Product = false) - { - return self::getLocalDir() . self::getPath($repository, $Product); - } - - /** - * [getRelativePath renvoie le chemin relatif au storage ] - * @param boolean $repository [description] - * @param boolean $Product [description] - * @return [type] [description] - */ - public static function getRelativePath($repository = false, $Product = false) - { - return self::getTenancyRoot() . self::getPath($repository, $Product); - } - - /** - * [getPath renvoie le chemin relatif à la tenancy root] - * @param boolean $repository [description] - * @param boolean $Product [description] - * @return [type] [description] - */ - public static function getPath($repository = false, $Product = false) - { - $path = '/'. self::getSlug($Product); - $path .= $repository ? $repository : ''; - return $path; - } - - /** - * [getStorage revoie le storage du tenant (local, S3, ...)] - * @return [type] [description] - */ - public static function getStorage() - { - return Storage::disk('tenant'); - } - - public static function getDirectory() - { - return app(\Hyn\Tenancy\Website\Directory::class); - } - - /** - * [getLocalDir renvoie le chemin complet vers la tenancy sur le disque] - * @return [type] [description] - */ - public static function getLocalDir() - { - return storage_path('app' . self::getTenancyRoot()); - } - - /** - * [getLocalPath revnoie le chemin public vers la tenancy publique] - * @return [type] [description] - */ - public static function getLocalPath() - { - return '/storage' . self::getTenancyRoot(); - } - - public static function getSlug($Product = false) - { - if ($Product) { - return $Product; - } - - $website = self::getWebsite(); - if ($website) { - return($website->uuid); - } - - /* - // regarde si le Product existe et qu'il possède au moins une licence valide pour une des applications - $host = array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : 'legtech.legtech'; - $url_hostname = explode(".", $host); // décompose l'url de base - $slug = $url_hostname[0]; - if ($slug == 'legstack') { - $slug = 'legtech'; - } - return $slug; - */ - } - - // récupère les informations de connexion à la base du Product - public static function getDatabaseEnvironment($Product_id) - { - return Product::byId($Product_id)->first()->toArray(); - } - - public static function isProduct() - { - $website = self::getWebsite(); - $is_Product = $website ? true : false; - return $is_Product; - } - - public static function getWebsite() - { - return \Hyn\Tenancy\Facades\TenancyFacade::website(); - } - - public static function getWebsiteByProduct($id) - { - $Product = Product::find($id); - return Website::find($Product->website_id); - } - } diff --git a/app/Repositories/Species.php b/app/Repositories/Species.php new file mode 100644 index 00000000..108d7cee --- /dev/null +++ b/app/Repositories/Species.php @@ -0,0 +1,54 @@ +make(true); + } + + public static function getAll() + { + return Specie::orderBy('name','asc')->get(); + } + + public static function get($id) + { + return Specie::find($id); + } + + public static function store($data) + { + $id = isset($data['id']) ? $data['id'] : false; + $item = $id ? self::update($data) : self::create($data); + return $item->id; + } + + public static function create($data) + { + return Specie::create($data); + } + + public static function update($data) + { + return Specie::find($id)->update($data); + } + + public static function destroy($id) + { + return Specie::destroy($id); + } + +} diff --git a/app/User.php b/app/User.php new file mode 100644 index 00000000..ee927fd7 --- /dev/null +++ b/app/User.php @@ -0,0 +1,225 @@ + 'datetime', + ]; + + public function teams() + { + 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('teams', function ($query) use ($id) { + $query->where('id', $id); + }); + } + + public function scopeByUniqueTeam($query) + { + return $query->has('teams', '=', 1); + } + + public function scopeActive($query) + { + return $query->where('active', 1); + } + + /** + * Send the password reset notification. + * + * @param string $token + * + * @return void + */ + public function sendPasswordResetNotification($token) + { + $this->notify(new ResetPasswordNotification($token)); + } + + /** + * Send notification when a new user is created. + * + * @param string $token + */ + public function sendNewUserNotification($token) + { + $this->notify(new NewUserNotification($token, $this)); + } + + /** + * Return last name in uppercase by default. + * + * @param $value + * + * @return string + */ + public function getLastNameAttribute($value) + { + return mb_strtoupper($value); + } + + /** + * Return first name with first char of every word in uppercase. + * + * @param $value + * + * @return string + */ + public function getFirstNameAttribute($value) + { + return mb_convert_case($value, MB_CASE_TITLE); + } + + /** + * Return a concatenation of first name and last_name if field name does not exists. + * + * @param $value + * + * @return string + */ + public function getNameAttribute($value) + { + if (!empty($value)) { + return $value; + } + + return $this->first_name.' '.$this->last_name; + } + + /** + * Return last login date formatted. + * + * @param string $format + * @param string $default + * + * @return mixed|string + */ + public function getLastLogin($format = 'YYYY-MM-DD HH:mm:ss', $default = '') + { + if ($this->last_login === null) { + return $default; + } + + return Carbon::createFromTimeString($this->last_login)->isoFormat($format); + } + + /** + * Return role list as a string. + * + * @return string + */ + public function getRolesList() + { + $res = []; + foreach ($this->roles as $role) { + $res[] = __($role->display_name); + } + if (empty($res)) { + return '-'; + } + + return implode(', ', $res); + } + + /** + * Check if current user has an avatar. + * + * @return string|false + */ + public function getAvatarPathAttribute() + { + return public_path('images/avatars/'.md5($this->id.$this->email).'.jpg'); + } + + /** + * Return current user avatar uri. + * + * @return string + */ + public function getAvatarUrlAttribute() + { + if (is_file($this->avatar_path)) { + $ts = filemtime($this->avatar_path); + + return asset('images/avatars/'.md5($this->id.$this->email).'.jpg?t='.$ts); + } + + return asset('/assets/vendor/boilerplate/images/default-user.png'); + } + +} diff --git a/resources/_back/auth/firstlogin.blade.php b/resources/_back/auth/firstlogin.blade.php deleted file mode 100644 index 7685c3bb..00000000 --- a/resources/_back/auth/firstlogin.blade.php +++ /dev/null @@ -1,42 +0,0 @@ -@extends('boilerplate::auth.layout', [ - 'title' => __('boilerplate::auth.firstlogin.title'), - 'bodyClass' => 'hold-transition login-page' -]) - -@section('content') - @component('boilerplate::auth.loginbox') - {{ Form::open(['route' => 'boilerplate.users.firstlogin', 'autocomplete' => 'off']) }} - -
{{ __('boilerplate::auth.login.intro') }}
- {!! Form::open(['route' => 'boilerplate.login', 'method' => 'post', 'autocomplete'=> 'off']) !!} -
- {{ __('boilerplate::auth.login.forgotpassword') }}
-
- {{ __('boilerplate::auth.login.register') }} -
- @endif - @endcomponent -@endsection diff --git a/resources/_back/auth/loginbox.blade.php b/resources/_back/auth/loginbox.blade.php deleted file mode 100644 index b628fd70..00000000 --- a/resources/_back/auth/loginbox.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -{{ __('boilerplate::auth.password.intro') }}
- @if (session('status')) -- {{ __('boilerplate::auth.password.login_link') }} -
- @if(config('boilerplate.auth.register')) -- {{ __('boilerplate::auth.login.register') }} -
- @endif - @endcomponent -@endsection diff --git a/resources/_back/auth/passwords/reset.blade.php b/resources/_back/auth/passwords/reset.blade.php deleted file mode 100644 index 9dd900b5..00000000 --- a/resources/_back/auth/passwords/reset.blade.php +++ /dev/null @@ -1,48 +0,0 @@ -@extends('boilerplate::auth.layout', ['title' => __('boilerplate::auth.password_reset.title')]) - -@section('content') - @component('boilerplate::auth.loginbox') -{{ __('boilerplate::auth.password_reset.intro') }}
- {!! Form::open(['route' => 'boilerplate.password.reset.post', 'method' => 'post', 'autocomplete'=> 'off']) !!} - {!! Form::hidden('token', $token) !!} -{{ __('boilerplate::auth.register.intro') }}
- {!! Form::open(['route' => 'boilerplate.register', 'method' => 'post', 'autocomplete'=> 'off']) !!} -
- {{ __('boilerplate::auth.register.login_link') }}
-