Add all files
This commit is contained in:
27
app/Livewire/Products/Show.php
Normal file
27
app/Livewire/Products/Show.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Products;
|
||||
|
||||
use App\Livewire\Component;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class Show extends Component
|
||||
{
|
||||
public $product;
|
||||
|
||||
public Category $category;
|
||||
|
||||
public function mount($product)
|
||||
{
|
||||
$this->product = $this->category->products()->where('slug', $product)->where('hidden', false)->firstOrFail();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('products.show')->layoutData([
|
||||
'title' => $this->product->name,
|
||||
'image' => $this->product->image ? Storage::url($this->product->image) : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user