FEATURE: move blog module into own repository
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Modules\Blog\Article\Pipeline\DisplayContent;
|
||||
|
||||
use App\CMS\Contracts\Content\DisplayPipeline\Process;
|
||||
use App\Models\Content\Content;
|
||||
use Illuminate\Support\Collection;
|
||||
use Modules\Blog\Article\Entities\Comment;
|
||||
use Modules\Blog\Article\Handlers\Article;
|
||||
|
||||
class LoadCommentsForBlogpost implements Process
|
||||
{
|
||||
/**
|
||||
* Process and modify given page
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle(Content & $content)
|
||||
{
|
||||
if ($content->moduleHandler != Article::class)
|
||||
return;
|
||||
|
||||
$content->comments = new Collection();
|
||||
if (isset($content->moduleSettings['allowComments']) && $content->moduleSettings['allowComments']) {
|
||||
$content->comments = Comment::where('content_id', $content->id)
|
||||
->with('author')
|
||||
->where('approved', 1)
|
||||
->orderBy('created_at')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Modules\Blog\Article\Pipeline\SaveContent;
|
||||
|
||||
use App\CMS\Contracts\Content\SavePipeline\Process;
|
||||
use App\Models\Content\Content;
|
||||
use Modules\Blog\Article\Handlers\Article;
|
||||
|
||||
class TurnCommentsOnOrOff implements Process
|
||||
{
|
||||
/**
|
||||
* Process and modify given page
|
||||
*
|
||||
* @param Content $content
|
||||
* @param array $input
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle(Content & $content, array & $input)
|
||||
{
|
||||
if (trim($content->moduleHandler, '\\') !== Article::class) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = $content->moduleSettings;
|
||||
$settings['allowComments'] = isset($input['allowComments']) ? (int)$input['allowComments'] : 0;
|
||||
$content->moduleSettings = $settings;
|
||||
$content->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user