Fix Invoice/Estimate template issues and Add Payment Receipt, Custom Payment Modes and Item units

This commit is contained in:
Jay Makwana
2020-01-05 07:22:36 +00:00
committed by Mohit Panjwani
parent 56a955befd
commit 4c33a5d88c
112 changed files with 5050 additions and 331 deletions

View File

@ -0,0 +1,119 @@
<?php
namespace Crater\Http\Controllers;
use Crater\PaymentMethod;
use Illuminate\Http\Request;
use Crater\Http\Requests\PaymentMethodRequest;
class PaymentMethodController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$paymentMethods = PaymentMethod::whereCompany($request->header('company'))
->latest()
->get();
return response()->json([
'paymentMethods' => $paymentMethods
]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(PaymentMethodRequest $request)
{
$paymentMethod = new PaymentMethod;
$paymentMethod->name = $request->name;
$paymentMethod->company_id = $request->header('company');
$paymentMethod->save();
return response()->json([
'paymentMethod' => $paymentMethod
]);
}
/**
* Display the specified resource.
*
* @param \Crater\PaymentMethod $paymentMethod
* @return \Illuminate\Http\Response
*/
public function show(PaymentMethod $paymentMethod)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \Crater\PaymentMethod $paymentMethod
* @return \Illuminate\Http\Response
*/
public function edit(PaymentMethod $paymentMethod)
{
return response()->json([
'paymentMethod' => $paymentMethod
]);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Crater\PaymentMethod $paymentMethod
* @return \Illuminate\Http\Response
*/
public function update(PaymentMethodRequest $request, PaymentMethod $paymentMethod)
{
$paymentMethod->name = $request->name;
$paymentMethod->company_id = $request->header('company');
$paymentMethod->save();
return response()->json([
'paymentMethod' => $paymentMethod
]);
}
/**
* Remove the specified resource from storage.
*
* @param \Crater\PaymentMethod $paymentMethod
* @return \Illuminate\Http\Response
*/
public function destroy(PaymentMethod $paymentMethod)
{
$payments = $paymentMethod->payments;
if ($payments->count() > 0) {
return response()->json([
'error' => 'payments_attached'
]);
}
$paymentMethod->delete();
return response()->json([
'success' => 'Payment method deleted successfully'
]);
}
}