First invoice implementation.
This commit is contained in:
64
app/Http/Controllers/Api/InvoiceitemController.php
Normal file
64
app/Http/Controllers/Api/InvoiceitemController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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',
|
||||
|
||||
]);
|
||||
|
||||
$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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user