不允许使用Laravel验证方法

时间:2017-06-21 08:51:13

标签: php laravel validation

我试图在我的控制器方法上设置验证,但在验证失败时,我收到错误,该方法不允许http异常。

我的控制器:

namespace App\Http\Controllers\Web;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Services\InvoicesService;

class InvoiceController extends Controller
{

private $invoice;

public function __construct(InvoicesService $invoice) {
    $this->invoice = $invoice;
}

public function startNewInvoice($id, $customer) 
{
    $ticket = $this->invoice->getTicketByInvoice($id);
    $ticket = $ticket->Ticket;
    return view('form', ['InvoiceId' => $id,'CustomerInfo' => $customer, 'records' => null, 'recordState' => null, 'ticket' => $ticket, 'invoices' => null]);
}

public function generateInvoice(Request $request)
{
    //dd($request);

    $this->validate($request, [
        'CustomerNumber' => 'required|numeric'
        ]);

    $invoiceId = $request->input('Invoice');
    $customer = array('CustomerCode' => $request->input('CustomerNumber'),'CustomerName' => $request->input('CustomerName'),'CustomerAddress' => $request->input('CustomerAddress'),
                      'CustomerVATCode' => $request->input('CustomerVatNumber'));

    $hash = $this->invoice->generateInvoice($invoiceId, $customer);

    $newInvoice = $this->invoice->newInvoice($request->input('CustomerNumber'), $hash->Id);

    return $this->startNewInvoice($newInvoice->Id, $customer);

}

}

任何帮助都会非常感激

0 个答案:

没有答案