optimized xcontroller & route

added client controller
pull/49/head
A1Gard 5 months ago
parent 2d3bb229c5
commit dc59afb928

@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers;
use App\Models\Post;
use Illuminate\Http\Request;
class ClientController extends Controller
{
//
public function welcome(){
$area = 'index';
$title = config('app.name');
$subtitle = getSetting('subtitle');
return view('client.welcome',compact('area','title','subtitle'));
}
public function post(Post $post){
$area = 'post';
$title = $post->title;
$subtitle = $post->subtitle;
return view('client.post',compact('area','post','title','subtitle'));
}
}

@ -133,9 +133,14 @@ abstract class XController extends Controller
/**
* Display the specified resource.
*/
public function show($user)
public function show($item)
{
$x = new $this->_MODEL_();
$m = $this->_MODEL_::where($x->getRouteKeyName(), $item)->first();
//
if (method_exists($m,'webUrl')){
return redirect($m->webUrl());
}
}

@ -124,7 +124,6 @@ class Post extends Model implements HasMedia
// }
public function webUrl(){
return '#';// WIP
return route('');
return route('client.post',$this->slug);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

@ -0,0 +1,13 @@
@extends('website.inc.website-layout')
@section('title')
{{$post->title}} - {{config('app.name')}}
@endsection
@section('content')
<main>
@foreach(getParts($area) as $part)
@php($p = $part->getBladeWithData())
@include($p['blade'],['data' => $p['data']])
@endforeach
</main>
@endsection

@ -2,7 +2,7 @@
<ul>
<li data-bs-toggle="tooltip" data-bs-placement="auto" data-bs-custom-class="custom-tooltip"
data-bs-title="{{__("xShop")}}">
<a href="{{route('welcome')}}" target="_blank">
<a href="{{route('client.welcome')}}" target="_blank">
<i class="ri-home-smile-fill"></i>
</a>
</li>

@ -9,6 +9,8 @@
h2{
opacity: .4;
margin-bottom: 3rem;
max-height: 2.1em;
overflow: hidden;
}
.fake-container{

@ -4,12 +4,7 @@ use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
$area = 'index';
$title = config('app.name');
$subtitle = getSetting('subtitle');
return view('welcome',compact('area','title','subtitle'));
})->name('welcome')->middleware(\App\Http\Middleware\VisitorCounter::class);
Auth::routes(['register' => false]);
@ -357,9 +352,15 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
});
Route::get('theme/variable.css',[\App\Http\Controllers\ThemeController::class,'cssVariables'])->name('theme.variable.css');
Route::name('client.')->group(function (){
// index
Route::get('/', [\App\Http\Controllers\ClientController::class,'welcome'])->name('welcome');
Route::get('/{post}', [\App\Http\Controllers\ClientController::class,'post'])->name('post');
})->middleware([\App\Http\Middleware\VisitorCounter::class]);
Route::get('test',function (){
// return \Resources\Views\Segments\PreloaderCircle::onAdd();
return getCategoryProductBySetting('index_TreeGridProducts_category');
@ -367,4 +368,3 @@ Route::get('test',function (){
})->name('test');

Loading…
Cancel
Save