F
F
fegedij3922020-09-26 13:54:23
Laravel
fegedij392, 2020-09-26 13:54:23

What is the best way to divide goods into warehouses?

Now I have done so
Goods

Route::get('/orders', 'admin\[email protected]');
Route::post('order-add', 'admin\[email protected]')->name('order-add');
Route::get('order-add', function () {
return view('cont.order-add');
})->name('order-add');


product controller OrdersController
public function addorder(OrdersRequest $addord)
    {
        $addorder = new Orders();
        $addorder->shop = $addord->input('shop');
        $addorder->product = $addord->input('product');
        $addorder->price = $addord->input('price');
        $addorder->warehouses = $addord->input('warehouses');
        $addorder->status = $addord->input('status');
        $addorder->comment = $addord->input('comment');

        $addorder->save();

        return redirect('/orders')->with('success', 'Ордер Добавлен!');
    }
public function orderlist()
    {
        $addorder = new Orders();
        return view('cont.orders', ['allorder' => Orders::all()]);
    }


output page of all critters
@foreach ($allorder as $order)
              <tr>
                  <td><a href="{{ route('order-one', $order->id) }}" class="btn btn-info">{{ $order->id }}</a></td>
                  <td>{{ $order->created_at }}</td>
                  <td>{{ $order->shop }}</td>
                  <td>{{ $order->product }}</td>
                  <td>{{ $order->price }}</td>
                  <td>{{ $order->warehouses }}</td>
                  <td>
                      <span class="badge-pill badge-primary">{{ $order->status }}</span>
                  </td>
                  <td>{{ $order->comment }}</td>
                <td>
                  <a href="{{ route('order-update', $order->id) }}" class="btn btn-info"
                    ><i class="fas fa-edit"><!-- --></i> </a>
                </td>
              </tr>
@endforeach


warehouses
Route::get('warehouses', 'admin\[email protected]');
Route::post('/warehouses-add', 'admin\[email protected]')->name('warehouses-add');
Route::get('/warehouses-add', function () {
        return view('work.warehouses-add');
    });

warehouse controller WarehousesController
public function addwarehouses(WarehousesRequest $addwrk)
    {
        $addwarehouses = new Warehouses();
        $addwarehouses->name = $addwrk->input('name');
        $addwarehouses->address = $addwrk->input('address');
        $addwarehouses->phone = $addwrk->input('phone');
        $addwarehouses->email = $addwrk->input('email');
        $addwarehouses->comment = $addwrk->input('comment');

        $addwarehouses->save();

        return redirect("Control-Panel")->with('success', 'Склад Добавлен!');
    }
    public function warehouseslist()
    {
        $addwarehousesr = new Warehouses;
        return view('work.warehouses', ['allwork' => Warehouses::all()]);
    }


all warehouses output page
@foreach ($allwork as $work)
                        <tr>
                            <td><a href="{{ route('warehouses-one', $work->id) }}" class="btn btn-info">{{ $work->id }}</a></td>
                            <td>{{ $work->name }}</td>
                            <td class="hidden-sm-down">{{ $work->address }}</td>
                            <td>{{ $work->phone }}<br>{{ $work->email }}</td>
                            <td>{{ $work->comment }}</td>
                            <td>
                                <a href=""{{ route('warehouses-update', $work->id) }}" class="btn btn-info"
                                    ><i class="fas fa-edit"><!-- --></i></a>
                                </td>
                        </tr>
@endforeach


Now there is no connection between them, just two tables.
How can I make sure that a certain product is assigned to the desired warehouse and when you go to the 'warehouses-one' warehouse page, all the products added to this warehouse are displayed there?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2020-09-26
@Sanes

Communication to many. How else?

V
Vladislav, 2020-09-26
@vos_50

In the table with goods, you make a warehouse_id column where you write the warehouse id. In the models you create links and through with in the request you get all the goods of a certain warehouse. Read the documentation, everything is clear on the examples shown.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question