Skip to content

Commit

Permalink
Merge pull request #614 from nasirkhan/dev
Browse files Browse the repository at this point in the history
UI update and fix
  • Loading branch information
nasirkhan authored Sep 21, 2024
2 parents c904b0e + f721d7f commit fb22f4d
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 345 deletions.
22 changes: 9 additions & 13 deletions Modules/Post/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
use Modules\Post\Enums\PostStatus;
use Modules\Post\Models\Presenters\PostPresenter;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
Expand Down Expand Up @@ -40,6 +41,11 @@ public function tags()
return $this->morphToMany('Modules\Tag\Models\Tag', 'taggable');
}

public function scopePublishedAndScheduled($query)
{
return $query->where('status', '=', PostStatus::Published->value);
}

/**
* Get the list of Published Articles.
*
Expand All @@ -48,20 +54,12 @@ public function tags()
*/
public function scopePublished($query)
{
return $query->where('status', '=', '1')
->where('published_at', '<=', Carbon::now());
}

public function scopePublishedAndScheduled($query)
{
return $query->where('status', '=', '1');
return $query->publishedAndScheduled()->where('published_at', '<=', Carbon::now());
}

public function scopeFeatured($query)
{
return $query->where('is_featured', '=', 'Yes')
->where('status', '=', '1')
->where('published_at', '<=', Carbon::now());
return $query->publishedAndScheduled()->where('is_featured', '=', 'Yes');
}

/**
Expand All @@ -72,9 +70,7 @@ public function scopeFeatured($query)
*/
public function scopeRecentlyPublished($query)
{
return $query->where('status', '=', '1')
->whereDate('published_at', '<=', Carbon::today()->toDateString())
->orderBy('published_at', 'desc');
return $query->publishedAndScheduled()->orderBy('published_at', 'desc');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Modules/Post/Resources/views/frontend/posts/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
$$module_name_singular->category->slug,
])" :text="$$module_name_singular->category_name" />
</p>
<p>
<div class="mt-4">
@foreach ($$module_name_singular->tags as $tag)
<x-frontend.badge :url="route('frontend.tags.show', [encode_id($tag->id), $tag->slug])" :text="$tag->name" />
@endforeach
</p>
</div>
</x-frontend.card>
@endforeach
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/BackendBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function index_list(Request $request)
foreach ($query_data as $row) {
$$module_name[] = [
'id' => $row->id,
'text' => $row->name.' (Slug: '.$row->slug.')',
'text' => $row->name,
];
}

Expand Down
Loading

0 comments on commit fb22f4d

Please sign in to comment.