コード例 #1
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
// Provide controller methods with object instead of ID
Route::model('users', 'User');
Route::model('pets', 'Pets');
Route::model('services', 'Services');
// Use slugs rather than IDs in URLs
Route::bind('users', function ($value, $route) {
    return App\User::whereid($value)->first();
});
Route::resource('users', 'UsersController');
Route::bind('pets', function ($value, $route) {
    return App\Pets::wherePet_name($value)->first();
});
Route::resource('pets', 'PetsController');
Route::bind('services', function ($value, $route) {
    return App\Services::whereService_name($value)->first();
});
Route::resource('services', 'ServicesController');
Route::bind('petsservicerelations', function ($value, $route) {
    return App\Petsservicerelations::whereService_id($value)->first();
    /*return App\Petsservicerelations::table('petsservicerelations')
      ->join('pets', 'petsservicerelations.pet_id', '=', 'pets.id')
      ->join('services', 'petsservicerelations.service_id', '=', 'services.id')