Compare commits

..

No commits in common. '974c2b9390ed35abfabb4892da8cbbeb21efe92a' and '5d807f11683ea31966ad0bd38fb822e01c7791b0' have entirely different histories.

@ -1,54 +0,0 @@
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

@ -20,7 +20,7 @@
## Access to xShop/v1 ## Access to xShop/v1
> [!WARNING] > [!WARNING]
> xShop/v1 available here: <a href="https://github.com/4xmen/xshop.v1">https://github.com/4xmen/xshop.v1</a> > xShop/v1 available here: <a href="https://github.com/a1Gard/xshop.v1">https://github.com/a1Gard/xshop.v1</a>
## Installation ## Installation

@ -816,48 +816,25 @@ function getGroupBySetting($key)
} }
/** /**
* get menu by setting key * get group by setting key
* @param $key * @param $key
* @return Menu * @return Menu
*/ */
function getMenuBySetting($key) function getMenuBySetting($key)
{ {
if (Menu::count() == 0) {
return [];
}
return Menu::where('id', getSetting($key) ?? 1)->first(); 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 * get group's posts by setting key
* @param $key * @param $key
* @param integer $limit * @param integer $limit
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C|array * @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
*/ */
function getGroupPostsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC") function getGroupPostsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC")
{ {
$g = Group::where('id', getSetting($key) ?? 1)->first(); return Group::where('id', getSetting($key) ?? 1)->first()
if ($g == null) { ->posts()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get();
return [];
}
return $g->posts()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get();
} }
/** /**
@ -880,15 +857,12 @@ function getCategoryProductBySetting($key, $limit = 10, $order = 'id', $dir = "D
* @param integer $limit * @param integer $limit
* @param string $order * @param string $order
* @param string $dir * @param string $dir
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C | array * @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
*/ */
function getCategorySubCatsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC") function getCategorySubCatsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC")
{ {
$c = Category::where('id', getSetting($key) ?? 1)->first(); return Category::where('id', getSetting($key) ?? 1)->first()
if ($c == null) { ->children()->orderBy($order, $dir)->limit($limit)->get();
return [];
}
return $c->children()->orderBy($order, $dir)->limit($limit)->get();
} }
/** /**
@ -1020,7 +994,6 @@ function postsUrl()
{ {
return fixUrlLang(\route('client.posts')); return fixUrlLang(\route('client.posts'));
} }
/** /**
* products url to best experience for multi lang shops * products url to best experience for multi lang shops
* @return string * @return string
@ -1029,7 +1002,6 @@ function productsUrl()
{ {
return fixUrlLang(\route('client.products')); return fixUrlLang(\route('client.products'));
} }
/** /**
* clips url to best experience for multi lang shops * clips url to best experience for multi lang shops
* @return string * @return string
@ -1038,7 +1010,6 @@ function clipsUrl()
{ {
return fixUrlLang(\route('client.clips')); return fixUrlLang(\route('client.clips'));
} }
/** /**
* galleries url to best experience for multi lang shops * galleries url to best experience for multi lang shops
* @return string * @return string
@ -1047,7 +1018,6 @@ function gallariesUrl()
{ {
return fixUrlLang(\route('client.galleries')); return fixUrlLang(\route('client.galleries'));
} }
/** /**
* attachments url to best experience for multi lang shops * attachments url to best experience for multi lang shops
* @return string * @return string
@ -1131,11 +1101,11 @@ function transports()
*/ */
function defTrannsport() 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 null;
} }
return \App\Models\Transport::where('is_default', 1)->first()->id; return \App\Models\Transport::where('is_default',1)->first()->id;
} }
@ -1144,8 +1114,7 @@ function defTrannsport()
* @param $array * @param $array
* @return false|string * @return false|string
*/ */
function vueTranslate($array) function vueTranslate($array){
{
return json_encode($array); return json_encode($array);
} }
@ -1168,7 +1137,7 @@ function markUpBreadcrumbList($items)
"name" => $index, "name" => $index,
]; ];
if ($item != '' || $item != null) { if ($item != '' || $item != null) {
$json[$i - 1]['item'] = $item; $json[$i-1]['item'] = $item;
} }
} }
@ -1197,9 +1166,9 @@ RESULT;
*/ */
function fixUrlLang($url) 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'); $welcome = \route('client.welcome');
return str_replace($welcome, $welcome . '/' . app()->getLocale(), $url); return str_replace($welcome,$welcome .'/'.app()->getLocale(),$url);
} }
return $url; return $url;
} }

@ -44,7 +44,7 @@ class TVisitor {
*/ */
public static function DetectOS() { public static function DetectOS() {
if (!isset($_SERVER['HTTP_USER_AGENT'])) if (!isset($_SERVER['HTTP_USER_AGENT']))
return null; return 'Unknown';
$os_list = Visitor::$osList; $os_list = Visitor::$osList;
@ -54,7 +54,7 @@ class TVisitor {
} }
} }
return null; return 'Unknown';
} }
/** /**
@ -118,7 +118,7 @@ class TVisitor {
*/ */
public static function DetectBrowser() { public static function DetectBrowser() {
if (!isset($_SERVER['HTTP_USER_AGENT'])) if (!isset($_SERVER['HTTP_USER_AGENT']))
return null; return 'Unknown';
$browser_list = Visitor::$browserList; $browser_list = Visitor::$browserList;
@ -128,7 +128,7 @@ class TVisitor {
} }
} }
return null; return 'Other';
} }
/** /**

@ -20,6 +20,8 @@ class AreaController extends Controller
public function desgin(Area $area) public function desgin(Area $area)
{ {
$valids = []; $valids = [];
foreach ($area->segment as $seg) { foreach ($area->segment as $seg) {
if (File::exists(resource_path() . '/views/segments/' . $seg)) { if (File::exists(resource_path() . '/views/segments/' . $seg)) {

@ -87,7 +87,7 @@ class PartSeeder extends Seeder
$part = new Part(); $part = new Part();
$part->segment = 'menu'; $part->segment = 'menu';
$part->part = 'AplMenu'; $part->part = 'AplMenu';
$part->area_id = Area::where('name', 'default_header')->first()->id; $part->area_id = Area::where('name', 'index')->first()->id;
$part->sort = 0; $part->sort = 0;
$part->save(); $part->save();

@ -13,7 +13,7 @@ class DenaAttachList
$setting->section = 'theme'; $setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_title'; $setting->key = $part->area->name . '_' . $part->part.'_title';
$setting->value = __("Website attachments list").' [ pdf, docx, zip, png, jpg, svg, mp4, rar, mp3 ]'; $setting->value = __("Website attachments list").' [ pdf, docx, zip, png, jpg, svg, mp4, rar, mp3 ]';
$setting->type = 'TEXT'; $setting->type = 'text';
$setting->size = 6; $setting->size = 6;
$setting->title = $part->area->name . ' ' . $part->part; $setting->title = $part->area->name . ' ' . $part->part;
$setting->save(); $setting->save();

@ -7,7 +7,7 @@
</a> </a>
</li> </li>
@foreach(getMenuBySettingItems($data->area->name.'_'.$data->part.'_menu') as $item) @foreach(getMenuBySetting($data->area->name.'_'.$data->part.'_menu')->items as $item)
<li> <li>
@if($item->meta == null) @if($item->meta == null)
<a href="{{$item->webUrl()}}"> <a href="{{$item->webUrl()}}">

@ -146,8 +146,4 @@
} }
} }
} }
~header{
margin-top: 44px;
}
} }

@ -5,7 +5,7 @@
<i class="ri-menu-line"></i> <i class="ri-menu-line"></i>
</a> </a>
</li> </li>
@foreach(getMenuBySettingItems($data->area->name.'_'.$data->part.'_menu') as $item) @foreach(getMenuBySetting($data->area->name.'_'.$data->part.'_menu')->items as $item)
<li> <li>
<a href="{{$item->webUrl()}}"> <a href="{{$item->webUrl()}}">
{{$item->title}} {{$item->title}}

@ -1,12 +1,12 @@
<section class='PostIndexImage'> <section class='PostIndexImage'>
<div class="{{gfx()['container']}}"> <div class="{{gfx()['container']}}">
<h1> <h1>
<a href="{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')?->webUrl()}}"> <a href="{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->webUrl()}}">
{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')?->name}} {{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->name}}
</a> </a>
</h1> </h1>
<p class="text-muted"> <p class="text-muted">
{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')?->description}} {{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->description}}
</p> </p>
<div class="row"> <div class="row">
@foreach( getGroupPostsBySetting($data->area->name.'_'.$data->part.'_group',4) as $post ) @foreach( getGroupPostsBySetting($data->area->name.'_'.$data->part.'_group',4) as $post )
@ -28,7 +28,7 @@
@endforeach @endforeach
</div> </div>
<div class="py-5 text-center"> <div class="py-5 text-center">
<a href="{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')?->webUrl()}}" class="btn btn-outline-primary"> <a href="{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->webUrl()}}" class="btn btn-outline-primary">
{{getSetting($data->area->name.'_'.$data->part.'_btn')}} {{getSetting($data->area->name.'_'.$data->part.'_btn')}}
</a> </a>
</div> </div>

@ -1,12 +1,12 @@
<section class='PostsIconSimple py-4'> <section class='PostsIconSimple py-4'>
<div class="{{gfx()['container']}}"> <div class="{{gfx()['container']}}">
<h1> <h1>
<a href="{{getGroupBySetting($data->area->name.'_'.$data->part)?->webUrl()}}"> <a href="{{getGroupBySetting($data->area->name.'_'.$data->part)->webUrl()}}">
{{getGroupBySetting($data->area->name.'_'.$data->part)?->name}} {{getGroupBySetting($data->area->name.'_'.$data->part)->name}}
</a> </a>
</h1> </h1>
<p> <p>
{{getGroupBySetting($data->area->name.'_'.$data->part)?->description}} {{getGroupBySetting($data->area->name.'_'.$data->part)->description}}
</p> </p>
<div class="row"> <div class="row">
@foreach(getGroupPostsBySetting($data->area->name.'_'.$data->part, getSetting($data->area->name.'_'.$data->part.'_limit')) as $post) @foreach(getGroupPostsBySetting($data->area->name.'_'.$data->part, getSetting($data->area->name.'_'.$data->part.'_limit')) as $post)
@ -20,7 +20,7 @@
{{$post->subtitle}} {{$post->subtitle}}
</p> </p>
<a href="{{$post?->webUrl()}}" class="btn btn-outline-primary w-100"> <a href="{{$post->webUrl()}}" class="btn btn-outline-primary w-100">
{{__("Read more")}} {{__("Read more")}}
</a> </a>
</div> </div>

@ -357,7 +357,7 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
}); });
Route::get('/theme/variable', [\App\Http\Controllers\ThemeController::class, 'cssVariables'])->name('theme.variable.css'); Route::get('theme/variable.css', [\App\Http\Controllers\ThemeController::class, 'cssVariables'])->name('theme.variable.css');
Route::middleware([\App\Http\Middleware\VisitorCounter::class]) Route::middleware([\App\Http\Middleware\VisitorCounter::class])
->name('client.')->group(function () { ->name('client.')->group(function () {

@ -1,75 +0,0 @@
<?php
namespace Tests\Feature;
use App\Models\Category;
use App\Models\Group;
use App\Models\Post;
use App\Models\Product;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ClientWebPagesTest extends TestCase
{
public function test_web_client_index(): void
{
$response = $this->get(route('client.welcome'));
$response->assertStatus(200);
}
public function test_web_client_posts(): void
{
$response = $this->get(route('client.posts'));
$response->assertStatus(200);
}
public function test_web_client_products(): void
{
$response = $this->get(route('client.products'));
$response->assertStatus(200);
}
public function test_web_client_product(): void
{
if (Product::count() == 0) {
Product::factory(1)->create();
}
$response = $this->get(Product::first()->webUrl());
$response->assertStatus(200);
}
public function test_web_client_post(): void
{
if (Post::count() == 0) {
Post::factory(1)->create();
}
$response = $this->get(Post::first()->webUrl());
$response->assertStatus(200);
}
public function test_web_client_group(): void
{
if (Group::count() == 0) {
Group::factory(1)->create();
}
$response = $this->get(Group::first()->webUrl());
$response->assertStatus(200);
}
public function test_web_client_category(): void
{
if (Category::count() == 0) {
Category::factory(1)->create();
}
$response = $this->get(Category::first()->webUrl());
$response->assertStatus(200);
}
}

@ -1,29 +0,0 @@
<?php
namespace Tests\Feature;
use App\Models\Customer;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class CustomerTest extends TestCase
{
public function check(){
if (Customer::count() == 0){
Customer::factory(1)->create();
}
}
/**
* A basic feature test example.
*/
public function test_customer_profile(): void
{
$this->check();
$response = $this->actingAs(Customer::inRandomOrder()->first(),'customer')->get(route('client.profile'));
$response->assertStatus(200);
}
}

@ -3,22 +3,17 @@
namespace Tests\Feature; namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase; // use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Log;
use Tests\TestCase; use Tests\TestCase;
class ExampleTest extends TestCase class ExampleTest extends TestCase
{ {
/** /**
* A basic test example. * A basic test example.
*/ */
public function test_the_application_returns_a_successful_response(): void public function test_the_application_returns_a_successful_response(): void
{ {
$response = $this->get('/');
$response = $this->get(route('client.welcome'));
$response->assertStatus(200); $response->assertStatus(200);
} }
} }

@ -1,20 +0,0 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class SiteMapTest extends TestCase
{
/**
* A basic feature test example.
*/
public function test_sitemap(): void
{
$response = $this->get(route('sitemap'));
$response->assertStatus(200);
}
}

@ -4,12 +4,12 @@ namespace Tests\Unit;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class SampleTest extends TestCase class ExampleTest extends TestCase
{ {
/** /**
* A basic unit test example. * A basic test example.
*/ */
public function test_example(): void public function test_that_true_is_true(): void
{ {
$this->assertTrue(true); $this->assertTrue(true);
} }
Loading…
Cancel
Save