Skip to content

Commit

Permalink
added tag page
Browse files Browse the repository at this point in the history
fixed readme
fixed map bugs (inline map & icons)
  • Loading branch information
A1Gard committed Sep 1, 2024
1 parent ddb5b34 commit b75f078
Show file tree
Hide file tree
Showing 18 changed files with 263 additions and 103 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ php artisan seeding:prepare
```
- Seeding image for models: [Group, Category, Post, Product, Slider]
```bash
pa seeding:image Product digital
php artisan seeding:image Product digital
```
> First parameter is Model, Second is image seeder directory available [bag, clothe, digital, sport, posts, makeup]
> You can create your directory and put your image into new directory then use image seeder
Expand Down
29 changes: 16 additions & 13 deletions app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function __construct()

$this->middleware(function ($request, $next) {

if ($request->attributes->get('set_lang') != true){
if ($request->attributes->get('set_lang') != true) {
app()->setLocale(config('app.locale'));
\Session::remove('locate');
}elseif (\Session::has('locate')) {
} elseif (\Session::has('locate')) {
app()->setLocale(\Session::get('locate'));
}

Expand Down Expand Up @@ -177,7 +177,12 @@ public function tag($slug)
{

$tag = Tag::where('slug->' . config('app.locale'), 'like', $slug)->first();
return $tag;
$posts = Post::withAnyTags([$tag])->where('status', 1)->paginate(100);
$products = Product::withAnyTags([$tag])->where('status', 1)->paginate(100);
$clips = Clip::withAnyTags([$tag])->where('status', 1)->paginate(100);
$title = __('Tag') . ': ' . $tag->name;
$subtitle = '';
return view('client.tag', compact('tag', 'posts', 'products', 'clips', 'title', 'subtitle'));
}


Expand Down Expand Up @@ -229,7 +234,7 @@ public function search(Request $request)
public function group($slug)
{

$group = Group::where('slug',$slug)->firstOrFail();
$group = Group::where('slug', $slug)->firstOrFail();
$area = 'group';
$title = $group->name;
$subtitle = $group->subtitle;
Expand Down Expand Up @@ -400,10 +405,6 @@ public function attachDl($slug)
}






public function compare()
{
$area = 'compare';
Expand All @@ -413,13 +414,15 @@ public function compare()
$products = Product::whereIn('id', $ids)->where('status', 1)->get();
return view('client.default-list', compact('area', 'products', 'title', 'subtitle'));
}

public function contact()
{
$area = 'contact-us';
$title = __("Contact us");
$subtitle = '';
return view('client.default-list', compact('area', 'title', 'subtitle'));
return view('client.default-list', compact('area', 'title', 'subtitle'));
}

public function sendContact(ContactSubmitRequest $request)
{
$con = new Contact();
Expand Down Expand Up @@ -581,14 +584,14 @@ public function lang(Request $request)
}
$method = explode('@', $r)[1];
$segments = $request->segments();
$routes = explode('/',$n);
$routes = explode('/', $n);
$args = [];
foreach ($routes as $i => $route) {
if ($route[0] == '{'){
$args[] = $segments[$i+1];
if ($route[0] == '{') {
$args[] = $segments[$i + 1];
}
}
$args[]= $request;
$args[] = $request;
return $this->$method(...$args);
}

Expand Down
31 changes: 18 additions & 13 deletions app/Models/Clip.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

class Clip extends Model
{
use HasFactory, SoftDeletes, HasTranslations,HasTags;
use HasFactory, SoftDeletes, HasTranslations, HasTags;

public $translatable = ['title','body'];
public $translatable = ['title', 'body'];

public function getRouteKeyName()
{
Expand All @@ -27,6 +27,7 @@ public function imgUrl()

return \Storage::url('cover/optimized-' . $this->cover);
}

public function imgOriginalUrl()
{
if ($this->cover == null) {
Expand All @@ -50,12 +51,14 @@ public function author()
return $this->belongsTo(\App\Models\User::class);
}

public function attachs(){
return $this->morphMany(Attachment::class,'attachable');
public function attachs()
{
return $this->morphMany(Attachment::class, 'attachable');
}

public function webUrl(){
return fixUrlLang(route('client.clip',$this->slug));
public function webUrl()
{
return fixUrlLang(route('client.clip', $this->slug));
}


Expand All @@ -69,12 +72,13 @@ public function approvedComments()
return $this->morphMany(Comment::class, 'commentable')->where('status', 1);
}

public function markup(){
public function markup()
{

$app = config('app.name');
$logo = asset('upload/images/logo.png');
$desc = str_replace('"','',strip_tags($this->body));
$count = $this->comments()->count() ;
$desc = str_replace('"', '', strip_tags($this->body));
$count = $this->comments()->count();
return <<<RESULT
<script type="application/ld+json">
Expand Down Expand Up @@ -106,11 +110,12 @@ public function markup(){

}

public function tagsList(){
if ($this->tags()->count() == 0){
public function tagsList()
{
if ($this->tags()->count() == 0) {
return getSetting('keyword');
}else{
return implode(',',$this->tags()->pluck('name')->toArray());
} else {
return implode(',', $this->tags()->pluck('name')->toArray());
}
}

Expand Down
49 changes: 27 additions & 22 deletions app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ public function registerMediaConversions(?Media $media = null): void
{

$optimize = getSetting('optimize');
if ($optimize == false){
if ($optimize == false) {
$optimize = 'webp';
}
$t = explode('x', config('app.media.post_thumb'));

$t = imageSizeConvertValidate('post_thumb');

$mc = $this->addMediaConversion('post-image')
$mc = $this->addMediaConversion('post-image')
->width($t[0])
->height($t[1])
->crop( $t[0], $t[1])
->crop($t[0], $t[1])
->optimize()
->sharpen(10)
->nonQueued()
->format($optimize);

if (getSetting('watermark')){
if (getSetting('watermark')) {
$mc->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent,
config('app.media.watermark_size'), Unit::Percent,
config('app.media.watermark_size'), Unit::Percent, Fit::Contain,
config('app.media.watermark_opacity'));
AlignPosition::BottomLeft, 5, 5, Unit::Percent,
config('app.media.watermark_size'), Unit::Percent,
config('app.media.watermark_size'), Unit::Percent, Fit::Contain,
config('app.media.watermark_opacity'));
}

}
Expand Down Expand Up @@ -106,12 +106,14 @@ public function approvedComments()
return $this->morphMany(Comment::class, 'commentable');
}

public function mainGroup(){
return $this->belongsTo(Group::class,'group_id');
public function mainGroup()
{
return $this->belongsTo(Group::class, 'group_id');
}

public function attachs(){
return $this->morphMany(Attachment::class,'attachable');
public function attachs()
{
return $this->morphMany(Attachment::class, 'attachable');
}


Expand All @@ -130,23 +132,25 @@ public function attachs(){
// ];
// }

public function webUrl(){
return fixUrlLang(route('client.post',$this->slug));
public function webUrl()
{
return fixUrlLang(route('client.post', $this->slug));
}


public function markup(){
public function markup()
{
$type = 'BlogPosting';
if (strpos(strtolower(implode(',',$this->groups()->pluck('name')->toArray())),__('article')) !== false){
if (strpos(strtolower(implode(',', $this->groups()->pluck('name')->toArray())), __('article')) !== false) {
$type = 'Article';
}
if (strpos(strtolower(implode(',',$this->groups()->pluck('name')->toArray())),__('news')) !== false){
if (strpos(strtolower(implode(',', $this->groups()->pluck('name')->toArray())), __('news')) !== false) {
$type = 'NewsArticle';
}

$app = config('app.name');
$logo = asset('upload/images/logo.png');
$author = $this->author->name??$app;
$author = $this->author->name ?? $app;
return <<<RESULT
<script type="application/ld+json">
{
Expand Down Expand Up @@ -184,11 +188,12 @@ public function markup(){

}

public function tagsList(){
if ($this->tags()->count() == 0){
public function tagsList()
{
if ($this->tags()->count() == 0) {
return getSetting('keyword');
}else{
return implode(',',$this->tags()->pluck('name')->toArray());
} else {
return implode(',', $this->tags()->pluck('name')->toArray());
}
}
}
Loading

0 comments on commit b75f078

Please sign in to comment.