Beispiel #1
0
    return $mahasiswa->dosen->nama;
});
Route::get('relasi-3', function () {
    $dosen = Dosen::where('nama', '=', 'Fazma Arif')->first();
    foreach ($dosen->mahasiswa as $temp) {
        echo '<li> Nama : ' . $temp->nama . ' <strong> (' . $temp->nim . ') </strong></li>';
    }
});
Route::get('relasi-4', function () {
    $ganin = Mahasiswa::where('nama', '=', 'Ganine Vinanda')->first();
    foreach ($ganin->hobi as $temp) {
        echo '<li>' . $temp->hobi . '</li>';
    }
});
Route::get('relasi-5', function () {
    $ngoding = Hobi::where('hobi', '=', 'Ngoding')->first();
    foreach ($ngoding->mahasiswa as $temp) {
        echo '<li> Nama : ' . $temp->nama . ' <strong>' . $temp->nim . '</strong></li>';
    }
});
Route::get('eloquent', function () {
    $mahasiswa = Mahasiswa::with('wali', 'dosen', 'hobi')->get();
    return View::make('eloquent', compact('mahasiswa'));
});
//DUMMY DATA-FAKER LIBRARY
get('blog', 'BlogController@index');
get('blog/{slug}', 'BlogController@showPost');
//FORM DAN VIEW
Route::get('article/create', 'ArticleController@add');
Route::get('article', 'ArticleController@index');
//Route::get('article/{id}','ArticleController@baca');