fixing styles
This commit is contained in:
@@ -41,7 +41,7 @@ class Roles
|
||||
return $role;
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
public static function toggleActive($id, $active)
|
||||
{
|
||||
return Role::find($id)->update(['active' => $active]);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace App\Repositories\Core\Auth;
|
||||
use App\Models\Core\Auth\Team;
|
||||
use App\Models\Core\Auth\TeamUser;
|
||||
use App\Repositories\Users;
|
||||
use App\Traits\Model\Basic;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
class Teams
|
||||
{
|
||||
use LaratrustUserTrait;
|
||||
use Basic, LaratrustUserTrait;
|
||||
|
||||
public static function getTeamsByUser($user_id = false)
|
||||
{
|
||||
@@ -34,48 +34,11 @@ class Teams
|
||||
return Team::find($id)->users();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Team::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getInfo($id)
|
||||
{
|
||||
return Team::find($id);
|
||||
}
|
||||
|
||||
public static function select_all()
|
||||
{
|
||||
return self::getAll()->toArray();
|
||||
}
|
||||
|
||||
public static function select_by_id($id)
|
||||
{
|
||||
return Team::find($id)->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Team::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Team::where('name', $name)->first();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Team::find($id);
|
||||
}
|
||||
|
||||
public static function getTable($id)
|
||||
{
|
||||
$datas = Team::with(['societe'])->withCount(['users']);
|
||||
|
||||
return Datatables::of($datas)->make(true);
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
Users::destroyByUniqueTeam($id);
|
||||
@@ -91,32 +54,8 @@ class Teams
|
||||
}
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
public static function getModel()
|
||||
{
|
||||
if (isset($data['id']) && $data['id']) {
|
||||
return self::update($data);
|
||||
}
|
||||
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Team::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Team::find($data['id'])->update($data);
|
||||
}
|
||||
|
||||
public static function count()
|
||||
{
|
||||
return Team::count();
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
{
|
||||
return Team::find($id)->update(['active' => $active]);
|
||||
return Team::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Repositories\Core\Auth;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
use App\Models\Core\Auth\User;
|
||||
use App\Repositories\Core\Upload;
|
||||
use App\Traits\Model\Basic;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -14,7 +15,7 @@ use Laratrust\Traits\LaratrustUserTrait;
|
||||
|
||||
class Users
|
||||
{
|
||||
use LaratrustUserTrait;
|
||||
use Basic, LaratrustUserTrait;
|
||||
|
||||
public static function isAdmin()
|
||||
{
|
||||
@@ -59,22 +60,6 @@ class Users
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$user = self::get($id);
|
||||
$ret = $user->update($data);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function get($id = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
|
||||
return User::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getId()
|
||||
{
|
||||
$user = self::getUser();
|
||||
@@ -206,32 +191,12 @@ class Users
|
||||
return User::select('id', DB::raw("concat(last_name,' ',first_name) as name"));
|
||||
}
|
||||
|
||||
public static function count()
|
||||
{
|
||||
return User::count();
|
||||
}
|
||||
|
||||
public static function select_all_by_status_id($status_id)
|
||||
{
|
||||
return User::byStatus($status_id);
|
||||
}
|
||||
|
||||
public static function select_by_id($user_id)
|
||||
{
|
||||
return User::with('status')->find($user_id)->toArray();
|
||||
}
|
||||
|
||||
public static function select_by_name($name)
|
||||
{
|
||||
return self::getByName($name)->toArray();
|
||||
}
|
||||
|
||||
public static function getByUsername($username)
|
||||
{
|
||||
return User::byUsername($username)->withTrashed()->first();
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
public static function toggleActive($id, $active)
|
||||
{
|
||||
return self::get($id)->update(['active' => $active]);
|
||||
}
|
||||
@@ -249,12 +214,12 @@ class Users
|
||||
];
|
||||
}
|
||||
|
||||
public static function update_avatar($id, $avatar)
|
||||
public static function updateAvatar($id, $avatar)
|
||||
{
|
||||
return User::find($id)->update(['avatar' => $avatar]);
|
||||
}
|
||||
|
||||
public static function update_password($id, $password)
|
||||
public static function updatePassword($id, $password)
|
||||
{
|
||||
$password = Hash::make($password);
|
||||
|
||||
@@ -265,4 +230,9 @@ class Users
|
||||
{
|
||||
return PasswordRules::changePassword($username, $field);
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return User::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Deliveries
|
||||
return Delivery::orderBy('name', 'asc')->active()->public()->with('sale_channel')->get();
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
public static function toggleActive($id, $active)
|
||||
{
|
||||
return self::update(['active' => $active], $id);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class Offers
|
||||
return Offer::with(['article.tags'])->byTags($tags)->get();
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $status_id)
|
||||
public static function toggleActive($id, $status_id)
|
||||
{
|
||||
return self::update(['status_id' => $status_id], $id);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,13 @@ class Packages
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
return [
|
||||
'families' => ArticleNatures::getOptions(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Package::orderBy('value', 'asc')->pluck('value', 'id')->toArray();
|
||||
|
||||
@@ -10,6 +10,15 @@ class PriceListValues
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
return [
|
||||
'unities' => Unities::getOptions(),
|
||||
'taxes_options' => Taxes::getOptions(),
|
||||
'categories' => PriceListValueCategories::getOptions(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPriceByOffer($offer_id, $quantity = 1, $sale_channel_id = false)
|
||||
{
|
||||
$prices = self::getPricesByOffer($offer_id, $sale_channel_id);
|
||||
|
||||
@@ -6,25 +6,11 @@ class Shelves
|
||||
{
|
||||
public static function getOffersByCategoryAndNature($categoryId, $articleNatureId = false, $tags = [], $articleNature = false, $displayByRows = false)
|
||||
{
|
||||
$productTypes = Articles::getProductTypesWithOffers([
|
||||
'category_id' => $categoryId,
|
||||
]);
|
||||
|
||||
$articleNatures = Articles::getArticleNaturesWithOffers([
|
||||
'category_id' => $categoryId,
|
||||
]);
|
||||
|
||||
if ($articleNatureId) {
|
||||
$productType = ArticleNatures::getProductType($articleNatureId);
|
||||
} else {
|
||||
if (! $articleNature) {
|
||||
if (count($articleNatures)) {
|
||||
$articleNature = $articleNatures[0];
|
||||
}
|
||||
}
|
||||
$productType = ArticleNatures::getProductTypeBySlug($articleNature);
|
||||
$articleNatureId = ArticleNatures::getIdBySlug($articleNature);
|
||||
}
|
||||
$articleNatures = Articles::getArticleNaturesWithOffers(['category_id' => $categoryId]);
|
||||
$productType = self::getProductType($articleNature, $articleNatures);
|
||||
$articleNatureId = $articleNatureId ?
|
||||
$articleNatureId :
|
||||
self::getArticleNatureId($articleNature, $articleNatures);
|
||||
|
||||
return [
|
||||
'category' => Categories::getFull($categoryId),
|
||||
@@ -33,7 +19,7 @@ class Shelves
|
||||
'product_type' => $productType,
|
||||
'article_nature' => $articleNature,
|
||||
'article_natures' => $articleNatures ?? [],
|
||||
'product_types' => $productTypes ?? [],
|
||||
'product_types' => Articles::getProductTypesWithOffers(['category_id' => $categoryId]),
|
||||
'tags_selected' => $tags,
|
||||
'articles' => Articles::getArticlesToSell([
|
||||
'category_id' => $categoryId,
|
||||
@@ -44,4 +30,27 @@ class Shelves
|
||||
'tags' => TagGroups::getWithTagsAndCountOffers($categoryId),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getArticleNatureId($articleNature, $articleNatures = [])
|
||||
{
|
||||
if (! $articleNature && count($articleNatures)) {
|
||||
$articleNature = $articleNatures[0];
|
||||
}
|
||||
|
||||
return ArticleNatures::getIdBySlug($articleNature);
|
||||
}
|
||||
|
||||
public static function getProductType($articleNatureId, $articleNature, $articleNatures = [])
|
||||
{
|
||||
if ($articleNatureId) {
|
||||
$productType = ArticleNatures::getProductType($articleNatureId);
|
||||
} else {
|
||||
if (! $articleNature && count($articleNatures)) {
|
||||
$articleNature = $articleNatures[0];
|
||||
}
|
||||
$productType = ArticleNatures::getProductTypeBySlug($articleNature);
|
||||
}
|
||||
|
||||
return $productType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user