[WIP] config Datatables/Webpack/Yajra

This commit is contained in:
Ludovic CANDELLIER
2020-04-12 04:09:36 +02:00
parent cd9b6ea74c
commit 134e04d197
49 changed files with 1204 additions and 670 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Repositories\Shop;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Yajra\DataTables\DataTables;
use App\Models\Shop\Family;
class Families
{
public static function getDatatable()
{
$model = Family::orderBy('name');
return Datatables::of($model)->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);
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Repositories\Shop;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Yajra\DataTables\DataTables;
use App\Models\Shop\Genre;
class Genres
{
public static function getDatatable()
{
$model = Genre::orderBy('name');
return Datatables::of($model)->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);
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Repositories;
namespace App\Repositories\Shop;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
@@ -15,203 +15,40 @@ class Products
public static function getDatatable()
{
$model = Product::with(['sections'])->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);
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Repositories\Shop;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Yajra\DataTables\DataTables;
use App\Models\Shop\Specie;
class Species
{
public static function getDatatable()
{
$model = Specie::orderBy('name');
return Datatables::of($model)->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);
}
}