用sql找不到请求模型

时间:2016-03-24 13:25:21

标签: php laravel laravel-5 laravel-5.1 laravel-routing

我想插入“发票”而不是“发票”。

问题是我在表发票中添加了执行行 我想现在在哪里可以找到与mysql说话的文件

InvoiceOutController.php

    public function create()
    {   
        $invoiceSettings    = InvoiceSetting::find(1);

        $data = array(
            'clients'       => Project::all(),
            'products'      => Product::where('status', 1)->get(),
            'currencies'    => Currency::all(),
            'taxes'         => Tax::orderBy('value', 'asc')->get(),
            'invoiceCode'   => isset($invoiceSettings->code)    
                     $invoiceSettings->code         : false,
                    'invoiceNumber' => isset($invoiceSettings->number)  ? 
                     $invoiceSettings->number + 1   : false
        );
        return View::make('user.invoiceout.create', $data);
    }

    public function store()
    {
        if ( Auth::user()->role_id != 1 )
        {
            return Redirect::to('dashboard')->with('error', trans('translate.permissions_denied'));
        }

        $rules = array(
            'client_id'     => 'required',
            'number'        => 'required',
            'start_date'    => 'required|date|date_format:"Y-m-d"',
            'due_date'      => 'required|date|date_format:"Y-m-d"',
            'currency_id'   => 'required'
        );

        $validator = Validator::make(Input::all(), $rules);

        if ($validator->passes())
        {
            $invoiceSettings = InvoiceSetting::first();

            if (isset($invoiceSettings->number))
            {
                $invoiceNumber              = $invoiceSettings->number + 1;
                $invoiceSettings->number    = $invoiceNumber;
                $invoiceSettings->save();
            }

            $store              = new Invoiceout;
            $store->number      = isset($invoiceSettings->number) ? $invoiceNumber : Input::get('number');
            $store->status_id   = 2;
            $store->discount    = Input::get('invoiceDiscount') ? Input::get('invoiceDiscount') : 0;
            $store->type        = Input::get('invoiceDiscountType') ? Input::get('invoiceDiscountType') : 0;
            $store->amount      = $store->calculateInvoice(Input::get('qty'), Input::get('price'), Input::get('taxes'), Input::get('discount'), Input::get('discountType'), Input::get('invoiceDiscount'), Input::get('invoiceDiscountType'));
            $store->fill(Input::all());
            $store->save();

            $products           = Input::get('products');

            foreach ($products as $k => $v)
            {
                $product                    = new InvoiceProduct;
                $product->invoice_id        = $store->id;
                $product->product_id        = $v;
                $product->quantity          = Input::get('qty')[$k];
                $product->price             = Input::get('price')[$k];
                $product->tax               = Input::get('taxes')[$k];
                $product->discount          = Input::get('discount')[$k] ? Input::get('discount')[$k] : 0;
                $product->discount_type     = Input::get('discountType')[$k] ? Input::get('discountType')[$k] : 0;
                $product->discount_value    = $store->calculateProductPrice(1, Input::get('qty')[$k], Input::get('price')[$k], Input::get('taxes')[$k], Input::get('discount')[$k], Input::get('discountType')[$k]);
                $product->amount            = $store->calculateProductPrice(2, Input::get('qty')[$k], Input::get('price')[$k], Input::get('taxes')[$k], Input::get('discount')[$k], Input::get('discountType')[$k]);
                $product->save();

                            App::make('ProductController')->manageQuantity($v, Input::get('qty')[$k], Input::get('price')[$k]);
            }

            $invoiceout = new Invoiceout;
            $invoiceout->invoiceStatus();


        }
        else
        {
            $invoiceSettings    = InvoiceSetting::find(1);

            $data = array(
                'clients'       => Project::all(),
                'products'      => Product::where('status', 1)->get(),
                'currencies'    => Currency::all(),
                'taxes'         => Tax::all(),
                'invoiceCode'   => isset($invoiceSettings->code)    ? $invoiceSettings->code        : false,
                            'invoiceNumber' => isset($invoiceSettings-
                             >number)   ? $invoiceSettings->number + 1  : false,
                            'errors'        => $validator->errors(),
                            'inputs'        => Input::all()
            );

            return View::make('user.invoiceout.create', $data);
        }

        return $this->loadDataTable();
    }

0 个答案:

没有答案