51 lines
1012 B
PHP
51 lines
1012 B
PHP
<?php
|
|
|
|
namespace Modules\Post\Http\Livewire;
|
|
|
|
use Livewire\Component;
|
|
use Livewire\Attributes\On;
|
|
use Modules\Post\Models\Post;
|
|
use Illuminate\Support\Facades\Storage;
|
|
class PostCard extends Component
|
|
{
|
|
public $id;
|
|
public function mount($id = false)
|
|
{
|
|
$this->id = $id;
|
|
}
|
|
|
|
#[On('showPostCardInModal')]
|
|
public function open($id)
|
|
{
|
|
$this->id = $id;
|
|
}
|
|
|
|
public function close()
|
|
{
|
|
$this->id = null;
|
|
}
|
|
public function render()
|
|
{
|
|
if ($this->id)
|
|
{
|
|
$post = Post::find($this->id);
|
|
if (Storage::disk('public')->exists($post->image))
|
|
{
|
|
$post->image = Storage::url($post->image);
|
|
}
|
|
else
|
|
{
|
|
$post->image = false;
|
|
}
|
|
return view('post::list.card', [
|
|
'post' => $post
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
return view('post::list.card', [
|
|
|
|
]);
|
|
}
|
|
}
|
|
} |