Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ArticlesController | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __invoke | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| approve | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| reject | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers; |
| 4 | |
| 5 | use App\Models\Article; |
| 6 | use App\Models\Setting; |
| 7 | use Illuminate\Contracts\View\View; |
| 8 | use Illuminate\Http\RedirectResponse; |
| 9 | use Illuminate\Http\Request; |
| 10 | |
| 11 | class ArticlesController extends Controller |
| 12 | { |
| 13 | public function __invoke(Request $request): View |
| 14 | { |
| 15 | $articles = Article::with('articlePublication') |
| 16 | ->orderBy('created_at', 'desc') |
| 17 | ->paginate(15); |
| 18 | |
| 19 | $publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled(); |
| 20 | |
| 21 | return view('pages.articles.index', compact('articles', 'publishingApprovalsEnabled')); |
| 22 | } |
| 23 | |
| 24 | public function approve(Article $article): RedirectResponse |
| 25 | { |
| 26 | $article->approve('manual'); |
| 27 | |
| 28 | return redirect()->back()->with('success', 'Article approved and queued for publishing.'); |
| 29 | } |
| 30 | |
| 31 | public function reject(Article $article): RedirectResponse |
| 32 | { |
| 33 | $article->reject('manual'); |
| 34 | |
| 35 | return redirect()->back()->with('success', 'Article rejected.'); |
| 36 | } |
| 37 | } |