fixed routes

pull/36/head
A1Gard 9 months ago
parent 65a74f80c8
commit ea26cc1155

@ -455,7 +455,7 @@ function getProductByCatQ($id, $order = 'id', $limit = 10)
* @param $id
* @return Cat[]|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Cat_C
*/
function getSubCats($id,$limit = 99)
function getSubCats($id, $limit = 99)
{
return Cat::where('parent_id', $id)->limit($limit)->get();
}
@ -603,8 +603,8 @@ function showMeta($key, $value)
*/
function time2persian($date, $format = 'Y/m/d')
{
if ($date == null){
return '-';
if ($date == null) {
return '-';
}
$dt = new TDate();
return $dt->PDate($format, $date);
@ -824,7 +824,7 @@ function sendSMSText2($number, $content)
//execute post
$result = curl_exec($ch);
return json_decode($result,true);
return json_decode($result, true);
}
/***
@ -874,3 +874,54 @@ function findLink($html)
return $match[1];
}
function showMenuMange2($arr)
{
$back = '';
$tr = '';
foreach ($arr as $menu) {
$ol = '';
if ($menu->children()->count() > 0) {
$ol = '<ol>' . showMenuMange2($menu->children()->orderBy('sort')->get()) . '</ol>';
}
if (config('app.xlang')) {
$l = route('admin.lang.model', [$menu->id, MenuItem::class]);
$tr = <<<TR
<a href="$l" class="float-end">
<i class="ri-translate"></i>
</a>
TR;
}
$back .= <<<LI
<li class="list-group-item"
data-menuabletype="$menu->menuable_type"
data-menuableid="$menu->menuable_id"
data-meta="$menu->meta"
data-kind="$menu->kind"
data-item-id="$menu->id"
data-title="$menu->title"
>
<span>
$menu->title
$tr
</span>
$ol
</li>
LI;
}
return $back;
}
function xroute($rt, $args = [])
{
if (config('app.xlang_main') != app()->getLocale()) {
return \route( $rt, $args);
} else {
return \route($rt, $args);
}
}

@ -66,5 +66,6 @@ class Kernel extends HttpKernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'under' => \App\Http\Middleware\UnderConstruction::class,
'lang' => \App\Http\Middleware\LangHandle::class,
];
}

@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL;
class LangHandle
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
app()->setLocale($request->route('lang'));
return $next($request);
}
}

@ -20,5 +20,22 @@
window.translate.errMobile = `{{ __('Incorrect mobile number') }}`;
window.translate.discountCodeError= `{{ __('Discount code incorrect') }}`;
window.translate.discountCodeAccept= `{{ __('Discount code accepted') }}`;
@if(request()->route('lang') != null)
// Get all anchor elements on the page
let links = document.getElementsByTagName('a');
const webBase = window.location.protocol + '//' + window.location.host;
// Loop through each anchor element
for (let i = 0; i < links.length; i++) {
let link = links[i];
// Check if the href attribute starts with webBase
if (link.href.indexOf(webBase) === 0) {
// Prefix '/en' to the href attribute
link.href = '/{{request()->route('lang')}}' + link.href.substring(webBase.length);
}
}
@endif
</script>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">

@ -130,7 +130,7 @@
>
@csrf
<ol class="menu-manage menu-x" id="menu-manage">
{!!\Xmen\StarterKit\Helpers\showMenuMange($menu->menuItems()->whereNull('parent')->orderBy('sort')->get())!!}
{!!\App\Helpers\showMenuMange2($menu->menuItems()->whereNull('parent')->orderBy('sort')->get())!!}
</ol>
<input type="hidden" name="info" value="[]" id="sorted"/>
<input type="button" id="save-menu" class="btn btn-primary" value="{{__("Save")}}">

@ -82,6 +82,7 @@
{{\App\Helpers\getSetting('copyright')}}
&copy; {{date('Y')}}
</div>
{{\App\Helpers\xroute('contact')}}
</div>
</div>
</div>

@ -23,29 +23,29 @@ Route::prefix(config('starter-kit.uri'))->name('admin.')->group(
Route::prefix('users')->name('user.')->group(
function () {
Route::get('/', [\App\Http\Controllers\Admin\UserController::class,'index'])->name('all');
Route::get('/delete/{user}', [\App\Http\Controllers\Admin\UserController::class,'destroy'])->name('delete');
Route::get('/create', [\App\Http\Controllers\Admin\UserController::class,'create'])->name('create');
Route::post('/store', [\App\Http\Controllers\Admin\UserController::class,'store'])->name('store');
Route::get('/edit/{user}', [\App\Http\Controllers\Admin\UserController::class,'edit'])->name('edit');
Route::post('/update/{user}', [\App\Http\Controllers\Admin\UserController::class,'update'])->name('update');
Route::get('/', [\App\Http\Controllers\Admin\UserController::class, 'index'])->name('all');
Route::get('/delete/{user}', [\App\Http\Controllers\Admin\UserController::class, 'destroy'])->name('delete');
Route::get('/create', [\App\Http\Controllers\Admin\UserController::class, 'create'])->name('create');
Route::post('/store', [\App\Http\Controllers\Admin\UserController::class, 'store'])->name('store');
Route::get('/edit/{user}', [\App\Http\Controllers\Admin\UserController::class, 'edit'])->name('edit');
Route::post('/update/{user}', [\App\Http\Controllers\Admin\UserController::class, 'update'])->name('update');
});
Route::prefix('langs')->name('lang.')->group(
function () {
Route::get('/', [\App\Http\Controllers\Admin\XlangController::class,'index'])->name('index');
Route::get('/translates', [\App\Http\Controllers\Admin\XlangController::class,'translate'])->name('translate');
Route::get('/delete/{xlang}', [\App\Http\Controllers\Admin\XlangController::class,'destroy'])->name('delete');
Route::get('/create', [\App\Http\Controllers\Admin\XlangController::class,'create'])->name('create');
Route::post('/store', [\App\Http\Controllers\Admin\XlangController::class,'store'])->name('store');
Route::get('/edit/{xlang}', [\App\Http\Controllers\Admin\XlangController::class,'edit'])->name('edit');
Route::post('/update/{xlang}', [\App\Http\Controllers\Admin\XlangController::class,'update'])->name('update');
Route::get('/', [\App\Http\Controllers\Admin\XlangController::class, 'index'])->name('index');
Route::get('/translates', [\App\Http\Controllers\Admin\XlangController::class, 'translate'])->name('translate');
Route::get('/delete/{xlang}', [\App\Http\Controllers\Admin\XlangController::class, 'destroy'])->name('delete');
Route::get('/create', [\App\Http\Controllers\Admin\XlangController::class, 'create'])->name('create');
Route::post('/store', [\App\Http\Controllers\Admin\XlangController::class, 'store'])->name('store');
Route::get('/edit/{xlang}', [\App\Http\Controllers\Admin\XlangController::class, 'edit'])->name('edit');
Route::post('/update/{xlang}', [\App\Http\Controllers\Admin\XlangController::class, 'update'])->name('update');
Route::post('bulk', [\App\Http\Controllers\Admin\XlangController::class, "bulk"])->name('bulk');
Route::get('/download/{tag}', [\App\Http\Controllers\Admin\XlangController::class,'download'])->name('download');
Route::get('/ai/{tag}', [\App\Http\Controllers\Admin\XlangController::class,'ai'])->name('ai');
Route::post('/upload/{tag}', [\App\Http\Controllers\Admin\XlangController::class,'upload'])->name('upload');
Route::get('/model/translate/{id}/{model}', [\App\Http\Controllers\Admin\XlangController::class,'translateModel'])->name('model');
Route::post('/model/translate/save/{id}/{model}', [\App\Http\Controllers\Admin\XlangController::class,'translateModelSave'])->name('modelSave');
Route::get('/model/ai/{id}/{model}/{field}/{lang}', [\App\Http\Controllers\Admin\XlangController::class,'translateModelAi'])->name('aiText');
Route::get('/download/{tag}', [\App\Http\Controllers\Admin\XlangController::class, 'download'])->name('download');
Route::get('/ai/{tag}', [\App\Http\Controllers\Admin\XlangController::class, 'ai'])->name('ai');
Route::post('/upload/{tag}', [\App\Http\Controllers\Admin\XlangController::class, 'upload'])->name('upload');
Route::get('/model/translate/{id}/{model}', [\App\Http\Controllers\Admin\XlangController::class, 'translateModel'])->name('model');
Route::post('/model/translate/save/{id}/{model}', [\App\Http\Controllers\Admin\XlangController::class, 'translateModelSave'])->name('modelSave');
Route::get('/model/ai/{id}/{model}/{field}/{lang}', [\App\Http\Controllers\Admin\XlangController::class, 'translateModelAi'])->name('aiText');
});
@ -197,7 +197,6 @@ Route::get('/props/list/{id}', [\App\Http\Controllers\Admin\PropController::clas
Route::group(
['middleware' => ['under']],
function () {
Route::get('/', [App\Http\Controllers\WebsiteController::class, 'index'])->name('welcome');
Route::get('/product-category/{cat}', [App\Http\Controllers\WebsiteController::class, 'cat'])->name('cat');
Route::get('/product/{pro}', [App\Http\Controllers\WebsiteController::class, 'product'])->name('product');
@ -232,6 +231,16 @@ Route::group(
Route::get('/ticket/{ticket}', [\App\Http\Controllers\CustomerController::class, 'ticket'])->name('ticket.show');
Route::get('/posts', [App\Http\Controllers\WebsiteController::class, 'posts'])->name('posts');
Route::get('/track', [App\Http\Controllers\WebsiteController::class, 'track'])->name('track');
Route::get('/redirect/bank/{invoice}/{gateway}', \App\Http\Controllers\Payment\GatewayRedirectController::class)->name('redirect.bank');
Route::any('/pay/check/{invoice_hash}/{gateway}', \App\Http\Controllers\Payment\GatewayVerifyController::class)->name('pay.check');
Route::get('/fav/toggle/{product}', [App\Http\Controllers\WebsiteController::class, 'favToggle'])->name('fav.toggle');
Route::post('/contact/send', [App\Http\Controllers\WebsiteController::class, "sendContact"])->name('sendcontact');
Route::get('/contact', [App\Http\Controllers\WebsiteController::class, "contact"])->name('contact');
Route::get('/reset', [App\Http\Controllers\WebsiteController::class, "reset"])->name('reset');
Route::get('/resetStock', [App\Http\Controllers\WebsiteController::class, "resetStockStatus"])->name('resetStock');
Route::get('/resetQ', [App\Http\Controllers\WebsiteController::class, "resetQuantity"])->name('resetQuantity');
Route::get('/credit/pay/{invoice}', [App\Http\Controllers\CustomerController::class, 'credit'])->name('credit');
Route::post('/invoice', [\App\Http\Controllers\Payment\GatewayRedirectController::class, 'createInvoice'])->middleware('auth:customer')->name('invoice.create');
});
Route::get('/underConstruct', function () {
@ -258,6 +267,21 @@ Route::prefix('')->name('n.')->group(function () {
// Route::post('assign', [App\Http\Controllers\WebsiteController::class, ''])->name('assign');
});
//Route::get('contact', [App\Http\Controllers\WebsiteController::class, "contact"])->name('contact');
//Route::get('mag', [App\Http\Controllers\WebsiteController::class, 'mag'])->name('mag');
Route::prefix('/{lang}')->name('lang.')->group(function () {
Route::group(
['middleware' => ['lang']],
function () {
Route::get('mag', [App\Http\Controllers\WebsiteController::class, 'mag'])->name('mag');
Route::get('contact', [App\Http\Controllers\WebsiteController::class, "contact"])->name('contact');
});
});
// site map
Route::get('/sitemap.xml', [App\Http\Controllers\SitemapController::class, 'index'])->name('sitemap.index');
Route::get('/sitemap/posts.xml', [App\Http\Controllers\SitemapController::class, 'posts'])->name('sitemap.posts');
@ -282,32 +306,23 @@ Auth::routes([
'register' => false,
]);
//
Route::post('/invoice', [\App\Http\Controllers\Payment\GatewayRedirectController::class, 'createInvoice'])->middleware('auth:customer')->name('invoice.create');
Route::get('/redirect/bank/{invoice}/{gateway}', \App\Http\Controllers\Payment\GatewayRedirectController::class)->name('redirect.bank');
Route::any('/pay/check/{invoice_hash}/{gateway}', \App\Http\Controllers\Payment\GatewayVerifyController::class)->name('pay.check');
Route::get('/fav/toggle/{product}', [App\Http\Controllers\WebsiteController::class, 'favToggle'])->name('fav.toggle');
Route::post('/contact/send', [App\Http\Controllers\WebsiteController::class, "sendContact"])->name('sendcontact');
Route::get('/contact', [App\Http\Controllers\WebsiteController::class, "contact"])->name('contact');
Route::get('/reset', [App\Http\Controllers\WebsiteController::class, "reset"])->name('reset');
Route::get('/resetStock', [App\Http\Controllers\WebsiteController::class, "resetStockStatus"])->name('resetStock');
Route::get('/resetQ', [App\Http\Controllers\WebsiteController::class, "resetQuantity"])->name('resetQuantity');
Route::get('/credit/pay/{invoice}', [App\Http\Controllers\CustomerController::class, 'credit'])->name('credit');
Route::get('/test/sms',function (){
if (auth()->check()){
$result = \App\Helpers\sendSMSText2('09209517726','پیامک');
if ($result == null){
return 'fatal error';
}else{
if ($result['OK']){
return $result['Msg'];
}else{
return 'err'.$result['Code'].': '.$result['Msg'];
}
}
} else{
return abort(403);
}
Route::get('/test/sms', function () {
if (auth()->check()) {
$result = \App\Helpers\sendSMSText2(\App\Helpers\getSetting('tel'), 'پیامک');
if ($result == null) {
return 'fatal error';
} else {
if ($result['OK']) {
return $result['Msg'];
} else {
return 'err' . $result['Code'] . ': ' . $result['Msg'];
}
}
} else {
return abort(403);
}
});

Loading…
Cancel
Save