Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI update and fix #614

Merged
merged 7 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading