mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
approve news items
This commit is contained in:
@@ -5,9 +5,24 @@ namespace App\Http\Livewire\News;
|
||||
use App\Models\LibraryItem;
|
||||
use Livewire\Component;
|
||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||
use WireUi\Traits\Actions;
|
||||
|
||||
class ArticleOverview extends Component
|
||||
{
|
||||
use Actions;
|
||||
|
||||
public function approve($id)
|
||||
{
|
||||
$libraryItem = LibraryItem::find($id);
|
||||
$libraryItem->approved = true;
|
||||
$libraryItem->save();
|
||||
|
||||
$this->notification()
|
||||
->success(__('Article approved'));
|
||||
|
||||
$this->emit('$reload');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.news.article-overview', [
|
||||
@@ -19,11 +34,22 @@ class ArticleOverview extends Component
|
||||
])
|
||||
->where('type', 'markdown_article')
|
||||
->when(app()->environment('production'),
|
||||
fn($query) => $query
|
||||
->whereHas('createdBy.roles',
|
||||
fn($query) => $query->where('roles.name', 'news-editor'))
|
||||
function ($query) {
|
||||
if (auth()->user() && auth()
|
||||
->user()
|
||||
->hasRole('news-editor')) {
|
||||
|
||||
}
|
||||
if (auth()->user() && !auth()
|
||||
->user()
|
||||
->hasRole('news-editor')) {
|
||||
$query
|
||||
->whereHas('createdBy.roles',
|
||||
fn($query) => $query->where('roles.name', 'news-editor'))
|
||||
->where('approved', true);
|
||||
}
|
||||
}
|
||||
)
|
||||
->where('approved', true)
|
||||
->orderByDesc('created_at')
|
||||
->get(),
|
||||
])->layout('layouts.app', [
|
||||
|
||||
Reference in New Issue
Block a user