added canonical tag to post, product, group, category

master
A1Gard 2 weeks ago
parent 0a33a22a36
commit 316452d7b7

@ -60,6 +60,9 @@ class CategoryController extends XController
if ($category->parent_id != ''){
$category->parent_id = $request->input('parent_id',null);
}
if ($request->has('canonical') && trim($request->input('canonical')) != ''){
$category->canonical = $request->input('canonical');
}
$category->slug = $this->getSlug($category);
if ($request->has('image')) {
$category->image = $this->storeFile('image', $category, 'categories');

@ -59,6 +59,9 @@ class GroupController extends XController
if ($group->parent_id != ''){
$group->parent_id = $request->input('parent_id',null);
}
if ($request->has('canonical') && trim($request->input('canonical')) != ''){
$group->canonical = $request->input('canonical');
}
$group->slug = $this->getSlug($group);
if ($request->has('image')){
$group->image = $this->storeFile('image',$group, 'groups');

@ -61,6 +61,10 @@ class PostController extends XController
$post->table_of_contents = $request->has('table_of_contents');
$post->icon = $request->input('icon');
if ($request->has('canonical') && trim($request->input('canonical')) != ''){
$post->canonical = $request->input('canonical');
}
if ($post->hash == null) {
$post->hash = date('Ym') . str_pad(dechex(crc32($post->slug)), 8, '0', STR_PAD_LEFT);
}

@ -77,11 +77,16 @@ class ProductController extends XController
$product->user_id = auth()->id();
$product->status = $request->input('status');
$tags = array_filter(explode(',,', $request->input('tags')));
if ($request->has('canonical') && trim($request->input('canonical')) != ''){
$product->canonical = $request->input('canonical');
}
$product->save();
$product->categories()->sync($request->input('cat'));
if (count($tags) > 0){
$product->syncTags($tags);
}
foreach ($product->getMedia() as $media) {
in_array($media->id, request('medias', [])) ?: $media->delete();
}

@ -28,6 +28,7 @@ class CategorySaveRequest extends FormRequest
'bg' => ['nullable', 'file', 'mimes:jpg,svg,png'],
'description' => ['nullable', 'string',],
'parent_id' => ['nullable', 'exists:categories,id'],
'canonical' => ['nullable', 'url', 'min:5', 'max:128'],
];
}
}

@ -28,6 +28,7 @@ class GroupSaveRequest extends FormRequest
'bg' => ['nullable', 'file', 'mimes:jpg,svg,png'],
'description' => ['nullable', 'string',],
'parent_id' => ['nullable', 'exists:groups,id'],
'canonical' => ['nullable', 'url', 'min:5', 'max:128'],
];
}
}

@ -30,6 +30,7 @@ class PostSaveRequest extends FormRequest
'image' => ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'],
'icon' => ['nullable', 'string', 'min:3'],
'group_id' => ['required', 'exists:groups,id'],
'canonical' => ['nullable', 'url', 'min:5', 'max:128'],
];
}
}

@ -29,7 +29,8 @@ class ProductSaveRequest extends FormRequest
'active' => ['nullable', 'boolean'],
'meta' => ['nullable'],
'category_id' => ['required', 'exists:categories,id'],
'image.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
'image.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'canonical' => ['nullable', 'url', 'min:5', 'max:128'],
];
}
}

@ -22,6 +22,7 @@ return new class extends Migration
$table->integer('sort')->default(0);
$table->unsignedInteger('parent_id')->nullable()->default(null)->index();
$table->json('theme')->nullable();
$table->text('canonical')->nullable();
$table->softDeletes();
$table->timestamps();
});

@ -28,6 +28,7 @@ return new class extends Migration
$table->string('icon', 128)->nullable();
$table->boolean('table_of_contents')->default(0);
$table->json('theme')->nullable();
$table->text('canonical')->nullable();
$table->string('promote')->nullable();
$table->softDeletes();
$table->timestamps();

@ -22,6 +22,7 @@ return new class extends Migration
$table->string('bg',2048)->nullable()->default(null);
$table->unsignedInteger('parent_id')->nullable()->default(null)->index();
$table->json('theme')->nullable();
$table->text('canonical')->nullable();
$table->softDeletes();
$table->timestamps();
});

@ -36,6 +36,7 @@ return new class extends Migration
$table->unsignedBigInteger('sell')->default(0);
$table->unsignedTinyInteger('image_index')->default(0);
$table->json('theme')->nullable();
$table->text('canonical')->nullable();
$table->string('promote')->nullable();
$table->softDeletes();
$table->timestamps();

@ -51,6 +51,22 @@
</div>
@endif
@if(isset($item))
<div class="item-list mb-3">
<div class="p-3">
<div class="form-group">
<label for="canonical" class="my-2">
{{__('Canonical')}}
</label>
<input type="text" id="canonical" name="canonical"
value="{{old('canonical',$item->canonical??null)}}"
placeholder="{{__('canonical')}}"
class="form-control">
</div>
</div>
</div>
@endif
</div>
<div class="col-lg-9 ps-xl-1 ps-xxl-1">
<div class="general-form ">

@ -49,6 +49,21 @@
</div>
</div>
@endif
@if(isset($item))
<div class="item-list mb-3">
<div class="p-3">
<div class="form-group">
<label for="canonical" class="my-2">
{{__('Canonical')}}
</label>
<input type="text" id="canonical" name="canonical"
value="{{old('canonical',$item->canonical??null)}}"
placeholder="{{__('canonical')}}"
class="form-control">
</div>
</div>
</div>
@endif
</div>

@ -80,6 +80,22 @@
</div>
@endif
@if(isset($item))
<div class="item-list mb-3">
<div class="p-3">
<div class="form-group">
<label for="canonical" class="my-2">
{{__('Canonical')}}
</label>
<input type="text" id="canonical" name="canonical"
value="{{old('canonical',$item->canonical??null)}}"
placeholder="{{__('canonical')}}"
class="form-control">
</div>
</div>
</div>
@endif
</div>
<div class="col-lg-9 ps-xl-1 ps-xxl-1">
<div class="general-form ">

@ -44,6 +44,15 @@
<div>
<div class="form-group">
<label for="canonical" class="my-2">
{{__('Canonical')}}
</label>
<input type="text" id="canonical" name="canonical"
value="{{old('canonical',$item->canonical??null)}}"
placeholder="{{__('canonical')}}"
class="form-control">
</div>
<div class="form-group">
<label for="table">
{{__('Description Table')}}

@ -45,6 +45,11 @@
<meta property="og:type" content="article" />
<meta name="description" content="{{Str::limit($post->subtitle,150)}}">
<meta name="keywords" content="{{$post->tagsList()}}">
@if(\Illuminate\Support\Str::isUrl($post->canonical) )
<link rel="canonical" href="{{$post->canonical}}" />
@endif
@elseif(isset($product))
{!! $product->markup() !!}
<meta property="og:title" content="{{$product->name}}"/>
@ -69,6 +74,18 @@
<meta name="availability" content="{{strtolower(str_replace('_','',$product->status))}}">
<meta name="guarantee" content="{{getSetting('guarantee')}}">
@if(\Illuminate\Support\Str::isUrl($product->canonical) )
<link rel="canonical" href="{{$product->canonical}}" />
@endif
@elseif(isset($group))
@if(\Illuminate\Support\Str::isUrl($group->canonical) )
<link rel="canonical" href="{{$group->canonical}}" />
@endif
@elseif(isset($category))
@if(\Illuminate\Support\Str::isUrl($category->canonical) )
<link rel="canonical" href="{{$category->canonical}}" />
@endif
@elseif(isset($clip))
{!! $clip->markup() !!}
<meta property="og:title" content="{{$clip->title}}" />

Loading…
Cancel
Save