Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SadeghPM committed Aug 26, 2024
2 parents 1691963 + 974c2b9 commit bdf3ef0
Show file tree
Hide file tree
Showing 39 changed files with 557 additions and 160 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Laravel

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
laravel-tests:

runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.2'
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: remove composer lock
run: rm composer.lock
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Dataseeder
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan migrate --seed
- name: Npm install
run: npm install
- name: client build
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan client
- name: npm build
run: npm run build
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

## Access to xShop/v1
> [!WARNING]
> xShop/v1 available here: <a href="https://github.com/a1Gard/xshop.v1">https://github.com/a1Gard/xshop.v1</a>
> xShop/v1 available here: <a href="https://github.com/4xmen/xshop.v1">https://github.com/4xmen/xshop.v1</a>

## Installation
Expand Down
57 changes: 44 additions & 13 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,25 +816,48 @@ function getGroupBySetting($key)
}

/**
* get group by setting key
* get menu by setting key
* @param $key
* @return Menu
*/
function getMenuBySetting($key)
{
if (Menu::count() == 0) {
return [];
}
return Menu::where('id', getSetting($key) ?? 1)->first();
}

/**
* get menu's items by setting key
* @param $key
* @return array
*/
function getMenuBySettingItems($key)
{
if (Menu::count() == 0) {
return [];
}
$r = Menu::where('id', getSetting($key) ?? 1)->first();
if ($r == null) {
$r = Menu::first();
}
return $r->items;
}

/**
* get group's posts by setting key
* @param $key
* @param integer $limit
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C|array
*/
function getGroupPostsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC")
{
return Group::where('id', getSetting($key) ?? 1)->first()
->posts()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get();
$g = Group::where('id', getSetting($key) ?? 1)->first();
if ($g == null) {
return [];
}
return $g->posts()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get();
}

/**
Expand All @@ -857,12 +880,15 @@ function getCategoryProductBySetting($key, $limit = 10, $order = 'id', $dir = "D
* @param integer $limit
* @param string $order
* @param string $dir
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C | array
*/
function getCategorySubCatsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC")
{
return Category::where('id', getSetting($key) ?? 1)->first()
->children()->orderBy($order, $dir)->limit($limit)->get();
$c = Category::where('id', getSetting($key) ?? 1)->first();
if ($c == null) {
return [];
}
return $c->children()->orderBy($order, $dir)->limit($limit)->get();
}

/**
Expand Down Expand Up @@ -994,6 +1020,7 @@ function postsUrl()
{
return fixUrlLang(\route('client.posts'));
}

/**
* products url to best experience for multi lang shops
* @return string
Expand All @@ -1002,6 +1029,7 @@ function productsUrl()
{
return fixUrlLang(\route('client.products'));
}

/**
* clips url to best experience for multi lang shops
* @return string
Expand All @@ -1010,6 +1038,7 @@ function clipsUrl()
{
return fixUrlLang(\route('client.clips'));
}

/**
* galleries url to best experience for multi lang shops
* @return string
Expand All @@ -1018,6 +1047,7 @@ function gallariesUrl()
{
return fixUrlLang(\route('client.galleries'));
}

/**
* attachments url to best experience for multi lang shops
* @return string
Expand Down Expand Up @@ -1101,11 +1131,11 @@ function transports()
*/
function defTrannsport()
{
if (\App\Models\Transport::where('is_default',1)->count() == 0){
if (\App\Models\Transport::where('is_default', 1)->count() == 0) {
return null;
}

return \App\Models\Transport::where('is_default',1)->first()->id;
return \App\Models\Transport::where('is_default', 1)->first()->id;
}


Expand All @@ -1114,7 +1144,8 @@ function defTrannsport()
* @param $array
* @return false|string
*/
function vueTranslate($array){
function vueTranslate($array)
{
return json_encode($array);
}

Expand All @@ -1137,7 +1168,7 @@ function markUpBreadcrumbList($items)
"name" => $index,
];
if ($item != '' || $item != null) {
$json[$i-1]['item'] = $item;
$json[$i - 1]['item'] = $item;
}
}

Expand Down Expand Up @@ -1166,9 +1197,9 @@ function markUpBreadcrumbList($items)
*/
function fixUrlLang($url)
{
if ( config('app.xlang.active') && app()->getLocale() != config('app.xlang.main')){
if (config('app.xlang.active') && app()->getLocale() != config('app.xlang.main')) {
$welcome = \route('client.welcome');
return str_replace($welcome,$welcome .'/'.app()->getLocale(),$url);
return str_replace($welcome, $welcome . '/' . app()->getLocale(), $url);
}
return $url;
}
8 changes: 4 additions & 4 deletions app/Helpers/TVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function DetectOSI() {
*/
public static function DetectOS() {
if (!isset($_SERVER['HTTP_USER_AGENT']))
return 'Unknown';
return null;

$os_list = Visitor::$osList;

Expand All @@ -54,7 +54,7 @@ public static function DetectOS() {
}
}

return 'Unknown';
return null;
}

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ public static function IsMobile() {
*/
public static function DetectBrowser() {
if (!isset($_SERVER['HTTP_USER_AGENT']))
return 'Unknown';
return null;

$browser_list = Visitor::$browserList;

Expand All @@ -128,7 +128,7 @@ public static function DetectBrowser() {
}
}

return 'Other';
return null;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/Http/Controllers/Admin/AreaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public function update(Request $request, Area $area)

logAdmin(__METHOD__, __CLASS__, $area->id);

if ($request->has('use_default')){
$area->use_default = 1;
$area->save();
}


return redirect()->back()->with(['message' => __('area :NAME of website updated', ['NAME' => $area->name])]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function save($category, $request)
$category->name = $request->input('name');
$category->subtitle = $request->input('subtitle');
$category->description = $request->input('description');
$category->parent_id = $request->input('parent_id');
if ($category->parent_id != ''){
$category->parent_id = $request->input('parent_id',null);
}
$category->slug = $this->getSlug($category);
if ($request->has('image')) {
$category->image = $this->storeFile('image', $category, 'categories');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function save($customer, $request)
{

$customer->name = $request->input('name');
if ($customer->credit != $request->input('credit')){
if ($customer->credit != $request->input('credit') && $customer->id != null){
$diff = $request->input('credit') - $customer->credit;
$customer->credit = $request->input('credit')??0 ;
$cr = new Credit();
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public function save($group, $request)
$group->name = $request->input('name');
$group->subtitle = $request->input('subtitle');
$group->description = $request->input('description');
$group->parent_id = $request->input('parent_id');
if ($group->parent_id != ''){
$group->parent_id = $request->input('parent_id',null);
}
$group->slug = $this->getSlug($group);
if ($request->has('image')){
$group->image = $this->storeFile('image',$group, 'groups');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function up(): void
$table->string('icon')->nullable();
$table->json('valid_segments');
$table->string('preview')->nullable();
$table->boolean('use_default')->default(true);
$table->timestamps();
});
}
Expand Down
33 changes: 27 additions & 6 deletions database/seeders/AreaSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public function run(): void
'preview' => null,
'icon' => 'ri-ai-generate',
],
[
'name' => 'default_header',
'valid_segments' => json_encode(
["top", "header", "other", "ads", "menu"]
),
'max' => 2,
'preview' => null,
'icon' => 'ri-window-line',
],
[
'name' => 'default_footer',
'valid_segments' => json_encode(
["footer", "other", "ads" , "groups"]
),
'max' => 2,
'preview' => null,
'icon' => 'ri-window-line rotate-180',
],
[
'name' => 'index',
'valid_segments' => json_encode(
Expand Down Expand Up @@ -71,7 +89,7 @@ public function run(): void
"parallax", "other", "clip", "comments", "ads", "attachments"]
),
'max' => 6,
'preview' => null,
'preview' => null,
'icon' => 'ri-video-line',
],
[
Expand All @@ -91,7 +109,7 @@ public function run(): void
"parallax", "other", "gallery", "comments", "ads", "attachments"]
),
'max' => 6,
'preview' => null,
'preview' => null,
'icon' => 'ri-image-line',
],
[
Expand All @@ -111,7 +129,7 @@ public function run(): void
"parallax", "other", "product", "comments", "ads", "attachments"]
),
'max' => 6,
'preview' => null,
'preview' => null,
'icon' => 'ri-vip-diamond-line',
],
[
Expand All @@ -131,7 +149,7 @@ public function run(): void
"parallax", "other", "attachment", "comments", "ads"]
),
'max' => 6,
'preview' => null,
'preview' => null,
'icon' => 'ri-attachment-line',
],
[
Expand Down Expand Up @@ -171,7 +189,7 @@ public function run(): void
"parallax", "other", "group", "ads", 'posts_page', "attachments"]
),
'max' => 6,
'preview' => null,
'preview' => null,
'icon' => 'ri-book-shelf-line',
],
// [
Expand Down Expand Up @@ -201,7 +219,7 @@ public function run(): void
"parallax", "other", "login", "ads"]
),
'max' => 6,
'preview' => 'client.login',
'preview' => 'client.sign-in',
'icon' => 'ri-login-circle-line',
],
[
Expand Down Expand Up @@ -252,6 +270,9 @@ public function run(): void
$a->valid_segments = $area['valid_segments'];
$a->icon = $area['icon'];
$a->preview = $area['preview'];
if ($area['name'] == 'index'){
$a->use_default = false;
}
$a->save();
}
}
Expand Down
Loading

0 comments on commit bdf3ef0

Please sign in to comment.