Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Jun 7, 2023
1 parent da0e268 commit bc537eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/MicroweberPackages/Content/Models/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ class Content extends Model

public function scopeActive($query)
{
return $query->where('is_active', 1)->where('is_deleted', 0);
return $query
->where('is_active', 1)
->where(function($subQuery) {
$subQuery
->whereNull('is_deleted')
->orWhere('is_deleted', 0);
});
}

public function related()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace MicroweberPackages\Modules\Comments\Http\LiveWire;

use Livewire\Component;
use MicroweberPackages\Content\Models\Content;

class UserCommentReplyComponent extends Component
{
Expand All @@ -26,6 +27,7 @@ public function render()
public function save()
{
$validate = [
'state.rel_id' => 'required|min:1',
'state.comment_body' => 'required|min:3',
];
if (!user_id()) {
Expand All @@ -35,13 +37,16 @@ public function save()

$this->validate($validate);

$comment = new \MicroweberPackages\Comment\Models\Comment();

if (isset($this->state['rel_id'])) {
$comment->rel_id = $this->state['rel_id'];
$comment->rel_type = 'content';
$countContent = Content::where('id', $this->state['rel_id'])->whereActive()->count();
if ($countContent == 0) {
$this->addError('state.rel_id', 'Content not found');
return;
}

$comment = new \MicroweberPackages\Comment\Models\Comment();
$comment->rel_id = $this->state['rel_id'];
$comment->rel_type = 'content';

if (isset($this->state['reply_to_comment_id'])) {
$comment->reply_to_comment_id = $this->state['reply_to_comment_id'];
}
Expand Down

0 comments on commit bc537eb

Please sign in to comment.