79 lines
1.5 KiB
PHP
79 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Product;
|
|
use Illuminate\Http\Request;
|
|
use App\Support\ApiDataTransformer;
|
|
use Inertia\Inertia;
|
|
|
|
|
|
class ProductController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function show()
|
|
{
|
|
return Inertia::render(
|
|
'Products',
|
|
['productsData' => $this->index()]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$products = Product::with(['category', 'unit'])->orderBy('title', 'asc')->get();
|
|
return ApiDataTransformer::snakeToCamel($products->toArray());
|
|
}
|
|
|
|
public function single($id)
|
|
{
|
|
$products = Product::with(['category', 'unit'])->findOrFail($id);
|
|
return ApiDataTransformer::snakeToCamel($products->toArray());
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(Product $product)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, Product $product)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(Product $product)
|
|
{
|
|
//
|
|
}
|
|
}
|