类型错误:传递给App \ Http \ Controllers \ UserController :: sendInvoice()的参数1必须是App \ TraitsFolder \ Request的实例

时间:2018-07-02 05:22:17

标签: php email laravel-5 eloquent

我一直在从事一个项目,但由于邮件错误而卡住,该错误指出我无法发送电子邮件,并且系统找不到指定的路径。

我的控制器功能:

public function orderSubmit(Request $request)
{
    if (Cart::count() == 0){
        session()->flash('message','Your Cart is Empty.');
        session()->flash('type','warning');
        return back();
    }else{

        $basic = BasicSetting::first();
        $order['user_id'] = Auth::user()->id;
        $order['order_number'] = strtoupper(Str::random(16));
        $order['subtotal'] = Cart::subtotal();
        $order['tax'] = Cart::tax();
        $order['total'] = Cart::total();
        $order['expire_time'] = Carbon::parse()->addMinutes($basic->expire_time);
        $r = Order::create($order);
        $cart = Cart::content();
        foreach ($cart as $c){
            $item['order_id'] = $r->id;
            $item['product_id'] = $c->id;
            $item['qty'] = $c->qty;
            OrderItem::create($item);
            $product = Product::findOrFail($c->id);
            $product->stock = $product->stock - $c->qty;
            $product->save();
        }
        $this->sendInvoice(Auth::user()->id,$r->id);
        session()->flash('message','Order Submitted Successfully.');
        session()->flash('type','success');
        return redirect()->route('payment',$r->order_number);
    }
}

我的sendInvoic函数:

    public function sendInvoice($userId, $orderId)

{
   $basic = BasicSetting::first();
    $user = User::findOrFail($userId);
    $userDetails = UserDetails::whereUser_id($userId)->first();
    $order = Order::findOrFail($orderId);
    $mail_val = [
        'email' => $user->email,
        'name' => $user->first_name.' '.$user->last_name,
        'g_email' => $basic->email,
        'g_title' => $basic->title,
        'subject' => $basic->title.' '.'Order Invoice  - '.$order->order_number,
    ];

    $tomail =  $mail_val['email'];
    $toname =  $mail_val['name'];
    $frommail =  $mail_val['g_email'];
    $fromtitle =  $mail_val['g_title'];
    $fromsubject =  $mail_val['subject'];

    $items = null;

    $logoUrl = asset('assets/images/logo.png');
    $invoiceNumber = $order->order_number;
    $invoiceDate = Carbon::parse($order->created_at)->format('F d, Y - h:i A');
    $companyDetails = $basic->title."<br>".$basic->phone."<br>".$basic->address;
    $userDetails = $userDetails->b_name."<br>".$userDetails->b_number."<br>".$userDetails->b_email;
    $paymentUrl = route('payment',$order->order_number);
    $subtotal = $basic->symbol.$order->subtotal;
    $total = $basic->symbol.$order->total;
    $totalTax = $basic->symbol.$order->tax;
    $tax = $basic->tax;
    $minute = $basic->expire_time;

    $orderItem = OrderItem::whereOrder_id($orderId)->get();
    foreach ($orderItem as $ot){
        $productName = $ot->product->name;
        $productPrice = $ot->product->current_price;
        $productSub = $basic->symbol.($ot->qty*$productPrice);
        $items .= '<tr class="item">
                <td>
                    '.$productName.'
                </td>
                <td style="text-align:center">
                    '.$basic->symbol.$productPrice.'
                </td>
                <td style="text-align:center">
                    '.$ot->qty.'
                </td>
                <td>
                    '.$productSub.'
                </td>
            </tr>';        }*/

    // Mail::send('emails.invoice', [
    //     'logoUrl'=>$logoUrl,
    //     'invoiceNumber'=>$invoiceNumber,
    //     'invoiceDate' => $invoiceDate,
    //     'companyDetails' => $companyDetails,
    //     'userDetails' => $userDetails,
    //     'paymentUrl' => $paymentUrl,
    //     'subtotal' => $subtotal,
    //     'total' => $total,
    //     'totalTax' => $totalTax,
    //     'tax' => $tax,
    //     'items' => $items,
    //     'minute' => $minute,

    // ], function ($m) use ($mail_val) {
    //     $m->from($mail_val['g_email'], $mail_val['g_title']);
    //     $m->to($mail_val['email'], $mail_val['name'])->subject($mail_val['subject']);
    // });

}

我的按钮功能:

public function orderOverview()
{
    $data['page_title'] = 'Order Overview';
    $data['userDetails'] = UserDetails::whereUser_id(Auth::user()->id)->first();
    return view('home.order-overview',$data);
}

0 个答案:

没有答案