FEATURE: merge template namespace and module alias
This commit is contained in:
@@ -4,7 +4,7 @@ return [
|
||||
'name' => 'Articles',
|
||||
'translatedName' => 'article::module.name',
|
||||
'translatedDescription' => 'article::module.description',
|
||||
'alias' => 'blog-article',
|
||||
'alias' => 'article',
|
||||
'handler' => \Modules\Blog\Article\Handlers\Article::class,
|
||||
'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class],
|
||||
'files' => ['start.php'],
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\ActionLog\ActionLogType;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Module;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Modules\Blog\Article\Entities\Comment;
|
||||
|
||||
class Article extends Handler implements ContentTitles, AdvancedContentModifier, InstallableModule
|
||||
@@ -25,8 +26,8 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
|
||||
*/
|
||||
public function render(Content $content, $parameters)
|
||||
{
|
||||
$content->comments = [];
|
||||
if (isset($content->moduleSettings->allowComments) && $content->moduleSettings->allowComments) {
|
||||
$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)
|
||||
|
||||
@@ -11,15 +11,9 @@ use Pingpong\Modules\Routing\Controller;
|
||||
|
||||
class CreateNewComment extends Controller
|
||||
{
|
||||
public function postNew(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, $articleId)
|
||||
public function store(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, \Modules\Blog\Article\Entities\Article $article)
|
||||
{
|
||||
$article = Content::where('id', $articleId)
|
||||
->where('moduleHandler', Article::class)
|
||||
->firstOrFail();
|
||||
|
||||
$article->moduleSettings = json_decode($article->moduleSettings);
|
||||
|
||||
if (!isset($article->moduleSettings->allowComments) || !$article->moduleSettings->allowComments) {
|
||||
if (!isset($article->moduleSettings['allowComments']) || !$article->moduleSettings['allowComments']) {
|
||||
return redirect()
|
||||
->route('page.content', ['url' => $article->url])
|
||||
->with('error', trans('article::comments.disabledComments'));
|
||||
@@ -28,7 +22,7 @@ class CreateNewComment extends Controller
|
||||
$content = $request->message;
|
||||
$user = Auth::user();
|
||||
if ($user) {
|
||||
$name = $user->name;
|
||||
$name = is_null($user->name) ? $user->email : $user->name;
|
||||
$email = $user->email;
|
||||
} else {
|
||||
$name = $request->name;
|
||||
|
||||
@@ -22,7 +22,7 @@ Route::group([
|
||||
// public routes
|
||||
Route::group(['middleware' => ['web'], 'namespace' => 'Visitor'], function () {
|
||||
|
||||
Route::post('comments/new/{id}', 'CreateNewComment@postNew')
|
||||
Route::post('comments/new/{article}', 'CreateNewComment@store')
|
||||
->name('comments.new');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user