Some checks failed
Build project image / Build-and-release-image (push) Failing after 3m1s
66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Invoice;
|
|
use App\Models\Invoiceitem;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class InvoiceitemController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index(Invoice $invoice): JsonResponse
|
|
{
|
|
return response()->json($invoice->items);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request, Invoice $invoice): JsonResponse
|
|
{
|
|
$itemData = $request->validate([
|
|
'amount' => 'required|numeric|min:0',
|
|
'discount' => 'numeric|nullable',
|
|
'tax' => 'required|numeric|min:0',
|
|
'price' => 'required|numeric|min:0',
|
|
'total' => 'required|numeric|min:0',
|
|
'name' => 'required|string',
|
|
'description' => 'nullable|string',
|
|
'article_number' => 'nullable|string',
|
|
'sort' => 'required|numeric|min:0',
|
|
]);
|
|
|
|
$item = $invoice->items()->create($itemData);
|
|
return response()->json($item);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(Invoiceitem $invoiceitem)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, Invoiceitem $invoiceitem)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(Invoiceitem $invoiceitem)
|
|
{
|
|
//
|
|
}
|
|
}
|