added markup json breadcrumb [seo]

pull/49/head
A1Gard 5 months ago
parent 2eb89ead83
commit 3b0017010b

@ -986,6 +986,47 @@ function homeUrl()
return \route('client.welcome');
}
/**
* posts url to best experience for multi lang shops
* @return string
*/
function postsUrl()
{
return \route('client.posts');
}
/**
* products url to best experience for multi lang shops
* @return string
*/
function productsUrl()
{
return \route('client.products');
}
/**
* clips url to best experience for multi lang shops
* @return string
*/
function clipsUrl()
{
return \route('client.clips');
}
/**
* galleries url to best experience for multi lang shops
* @return string
*/
function gallariesUrl()
{
return \route('client.galleries');
}
/**
* attachments url to best experience for multi lang shops
* @return string
*/
function attachmentsUrl()
{
return \route('client.attachments');
}
/**
* tag url to best experience for multi lang shops
* @return string
@ -1054,6 +1095,10 @@ function transports()
return \App\Http\Resources\TransportCollection::collection(\App\Models\Transport::all());
}
/**
* default transport
* @return int|mixed|null
*/
function defTrannsport()
{
if (\App\Models\Transport::where('is_default',1)->count() == 0){
@ -1064,6 +1109,51 @@ function defTrannsport()
}
/**
* make translate json to use vue components
* @param $array
* @return false|string
*/
function vueTranslate($array){
return json_encode($array);
}
/**
* markup json Breadcrumb maker
* @param $items
* @return string
*/
function markUpBreadcrumbList($items)
{
$json = [];
$i = 0;
foreach ($items as $index => $item) {
$i++;
$json[] = [
"@type" => "ListItem",
"position" => $i,
"name" => $index,
];
if ($item != '' || $item != null) {
$json[$i-1]['item'] = $item;
}
}
$json = json_encode($json);
return <<<RESULT
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": $json
}
</script>
RESULT;
}

@ -42,7 +42,12 @@ class ClientController extends Controller
$title = $post->title;
$subtitle = $post->subtitle;
$post->increment('view');
return view('client.post', compact('area', 'post', 'title', 'subtitle'));
$breadcrumb = [
__('Posts') => postsUrl(),
$post->mainGroup->name => $post->mainGroup->webUrl(),
$post->title => null,
];
return view('client.post', compact('area', 'post', 'title', 'subtitle', 'breadcrumb'));
}
public function clip(Clip $clip)
@ -54,7 +59,11 @@ class ClientController extends Controller
$area = 'clip';
$title = $clip->title;
$subtitle = '';
return view('client.default-list', compact('area', 'clip', 'title', 'subtitle'));
$breadcrumb = [
__('Video clips') => clipsUrl(),
$clip->title => null,
];
return view('client.default-list', compact('area', 'clip', 'title', 'subtitle', 'breadcrumb'));
}
public function gallery(Gallery $gallery)
@ -66,7 +75,11 @@ class ClientController extends Controller
$title = $gallery->title;
$subtitle = \Str::limit(strip_tags($gallery->description), 15);
$gallery->increment('view');
return view('client.gallery', compact('area', 'gallery', 'title', 'subtitle'));
$breadcrumb = [
__('Galleries') => gallariesUrl(),
$gallery->title => null,
];
return view('client.gallery', compact('area', 'gallery', 'title', 'subtitle', 'breadcrumb'));
}
public function posts()
@ -90,7 +103,6 @@ class ClientController extends Controller
}
public function galleries()
{
$area = 'galleries-list';
@ -100,6 +112,7 @@ class ClientController extends Controller
->orderByDesc('id')->paginate($this->paginate);
return view('client.default-list', compact('area', 'galleries', 'title', 'subtitle'));
}
public function clips()
{
$area = 'clips-list';
@ -119,12 +132,17 @@ class ClientController extends Controller
->orderByDesc('id')->paginate($this->paginate);
return view('client.default-list', compact('area', 'attachs', 'title', 'subtitle'));
}
public function attachment(Attachment $attachment)
{
$area = 'attachment';
$title = $attachment->title;
$subtitle = $attachment->subtitle;
return view('client.default-list', compact('area', 'attachment', 'title', 'subtitle'));
$breadcrumb = [
__('Attachments') => attachmentsUrl(),
$attachment->title => null,
];
return view('client.default-list', compact('area', 'attachment', 'title', 'subtitle', 'breadcrumb'));
}
public function tag($slug)
@ -186,7 +204,21 @@ class ClientController extends Controller
$title = $group->name;
$subtitle = $group->subtitle;
$posts = $group->posts()->where('status', 1)->orderByDesc('id')->paginate($this->paginate);
return view('client.group', compact('area', 'posts', 'title', 'subtitle', 'group'));
if ($group->parent_id == null) {
$breadcrumb = [
__('Posts') => postsUrl(),
$group->name => null,
];
} else {
$breadcrumb = [
__('Posts') => postsUrl(),
$group->parent->name => $group->parent->webUrl(),
$group->name => null,
];
}
return view('client.group', compact('area', 'posts', 'title', 'subtitle', 'group', 'breadcrumb'));
}
public function product(Product $product)
@ -197,7 +229,15 @@ class ClientController extends Controller
$area = 'product';
$title = $product->name;
$subtitle = $product->excerpt; // WIP SEO
return view('client.default-list', compact('area', 'product', 'title', 'subtitle'));
$breadcrumb = [
__('Products') => productsUrl(),
$product->category->name => $product->category->webUrl(),
];
if ($product->category->parent_id != null) {
$breadcrumb[$product->category->parent->name] = $product->category->parent->webUrl();
}
$breadcrumb[$product->name] = null;
return view('client.default-list', compact('area', 'product', 'title', 'subtitle', 'breadcrumb'));
}
public function category(Category $category, Request $request)
@ -299,7 +339,21 @@ class ClientController extends Controller
$products = $query->paginate($this->paginate);
return view('client.category', compact('area', 'products', 'title', 'subtitle', 'category'));
if ($category->parent_id == null) {
$breadcrumb = [
__('Products') => productsUrl(),
$category->name => null,
];
} else {
$breadcrumb = [
__('Products') => productsUrl(),
$category->parent->name => $category->parent->webUrl(),
$category->name => null,
];
}
return view('client.category', compact('area', 'products', 'title', 'subtitle', 'category', 'breadcrumb'));
}
public function attachDl(Attachment $attachment)
@ -312,8 +366,6 @@ class ClientController extends Controller
}
public function productCompareToggle(Product $product)
{
if (\Cookie::has('compares')) {
@ -436,7 +488,7 @@ class ClientController extends Controller
$customer = Customer::where('mobile', $request->input('tel'));
$code = rand(11111, 99999);
Log::info('auth code: '.$code );
Log::info('auth code: ' . $code);
if ($customer->count() == 0) {
$customer = new Customer();
$customer->mobile = $request->input('tel');
@ -492,5 +544,4 @@ class ClientController extends Controller
}
}

@ -48,7 +48,7 @@
@endforeach
</div>
<div class="p-4 text-center mt-2">
<a href="{{route('client.products')}}" class="btn btn-secondary">
<a href="{{productsUrl()}}" class="btn btn-secondary">
{{__("All products")}}
</a>
</div>

@ -17,7 +17,9 @@
@yield('custom-head')
{{-- WIP rtl or ltr--}}
@if(isset($breadcrumb))
{!! markUpBreadcrumbList($breadcrumb) !!}
@endif
</head>
<body @yield('body-attr')>

Loading…
Cancel
Save