1

I'm new to this laravel. I have this codes from another developer. Now the client want to update the order form products to put in into checkbox the list of products.

Here how product blade looks like:

<input type="checkbox" name="product[]" value="{{ $pp->name }}"> {{ $pp->name }}<br />

and below is the controller: I get "ARRAY" printed as result. Can anyone help me how to get the product array values from checkbox.

function post_sendorder(){

$rules = array(
    'name' => 'required|min:2',
    'email' => 'required|email',
    'phone' => 'required|alpha_dash',
    'message' => 'required|min:5',
'product' => 'required'
);

$v = Validator::make(Input::all(), $rules);
$v = $v->fails() ? $v : true;

if($v !== true) return Redirect::to_route('prods')->with_errors($v->errors)->with_input()->with('show_order',true);

Message::send(function($message){
        $message->to('[email protected]');         
        $message->from(Input::get('email'), Input::get('name'));
        $message->subject('Keratin Product Order Form');
        $message->body(
            '<!doctype html>
            <html>
            <body>'.
            'Name: '.Input::get('name').'<br />'.
            'Email: '.Input::get('email').'<br />'.
            'Phone: '.Input::get('phone').'<br />'.     
            'Product Ordered:' .Input::get('product'). '<br />'.
            'Message: '.Input::get('message').'<br />'.
            '</body>
</html>'
        );

        $message->html(true);

    });

    if(Message::was_sent()){
        return Redirect::to_route('prods')->with('s-message','Your Order     Form has been successfully sent!')->with('show_order',true);
    }else{
        return Redirect::to_route('prods')->with('e-message','Sending Failed!')->with('show_order',true);
    }   

}
1

1 Answer 1

1

Input::get('product') is the array of product names (name="product[]" value="{{ $pp->name }}").

Instead of 'Product Ordered:' .Input::get('product') you need

'Products Ordered:' . implode(', ', Input::get('product'))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.