Initial commit
This commit is contained in:
13
app/Livewire/Tools/Coments.php
Normal file
13
app/Livewire/Tools/Coments.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Tools;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Coments extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.tools.coments');
|
||||
}
|
||||
}
|
||||
50
app/Livewire/Tools/HomeComments.php
Normal file
50
app/Livewire/Tools/HomeComments.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Tools;
|
||||
|
||||
use App\Models\Comment;
|
||||
use Livewire\Attributes\Rule;
|
||||
use Livewire\Component;
|
||||
|
||||
class HomeComments extends Component
|
||||
{
|
||||
|
||||
|
||||
public Comment $comments;
|
||||
public Comment $comment;
|
||||
|
||||
#[Rule('required')]
|
||||
public $comment_name;
|
||||
#[Rule('required')]
|
||||
public $comment_message;
|
||||
public $comment_name_reply;
|
||||
public $comment_message_reply;
|
||||
|
||||
public $blog_id;
|
||||
public $comment_id;
|
||||
|
||||
public function mount($comments,$comment,$blog_id)
|
||||
{
|
||||
$this->comments = $comments;
|
||||
$this->comment = $comment;
|
||||
$this->blog_id = $blog_id;
|
||||
// dd($this->comment);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.tools.home-comments');
|
||||
}
|
||||
|
||||
public function reply($id,$parent_id)
|
||||
{
|
||||
if ($this->comment_message_reply && $this->comment_name_reply){
|
||||
|
||||
Comment::create(['name'=>$this->comment_name_reply,'message'=>$this->comment_message_reply,'blog_id'=>$this->blog_id,'ip'=>request()->ip(),'user_agent'=>request()->userAgent(),'parent_id'=>$id,'type'=>2]);
|
||||
Comment::where('id',$parent_id)->increment('reply');
|
||||
$this->comment_message_reply=null;
|
||||
$this->comment_name_reply=null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user