Randy_Johnson
2 months ago

Sending and opening multiple varibles in the view.

Posted 2 months ago by Randy_Johnson

Hello, I am trying to make a create order page. I am just wondering what is the proper way of doing it.

Undefined variable: data (View: C:\Users\Josh\Desktop\websites\ecommerce\resources\views\admin\order\create.blade.php)
    public function create() 
    {
        $data = [
            'users' => DB::table('users')->get(),
            'products' => DB::table('products')->get()
        ];
        return view($this->cv, [$this->table => $data]);
    }
<form method="POST" action="/store-order">
                                @csrf
                                <div class="form-group">
                                    <label for="exampleFormControlSelect1">User</label>
                                    <select name="kilogram" class="form-control">
                                    @foreach($data['users'] as $user)
                                    <option>0.25</option>
                                    @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="exampleFormControlSelect1">Product</label>
                                    <select name="kilogram" class="form-control">
                                    <option>0.25</option>
                                    <option>0.5</option>
                                    <option>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                    </select>
                                </div>
                                <button type="submit" class="btn btn-primary float-right">Create</button>
                            </form>

Please sign in or create an account to participate in this conversation.