lundi 30 octobre 2017

Eloquent tables in Laravel 5

I work by a company with college What i programming is a web to make my college register what he/she online has ordered. Let's begin with my tables:

Services table:

--------------------
  id  |    name    |
--------------------
  1   |    DHL     |
--------------------
  2   |    TNT     |

User table:

--------------------
  id  |    name    |
--------------------
  1   |   Safwan   |
--------------------
  2   |    Niels   |

Packeges table:

---------------------------------------------
  id  | package_name | user_id | Services_id |    
---------------------------------------------
  1   |     Mouse    |    1    |      2      |
---------------------------------------------
  2   |   Keyboard   |    2    |      1      |

user_id is foreign with User.id and Services_id is foreign with Services.id

View controller:

public function index()
{
    // get all packages
    $package = package::all();

    return view('Pages.view', ['package' => $package]);


}

view.blade.php:

<h1>The ordered packages</h1>

            @foreach($package as $packages)
                
            @endforeach

Now what i want is that: Safwan ordered Mouse via TNT



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire