Пример #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /**
      * 值得注意的是,relation类调用时只能使用query builder的方法
      */
     factory(\App\Sheet::class, 10)->create()->each(function ($sheet) {
         $sheet->where('song_id', $sheet->song_id)->update(App\Song::getShortDescribe($sheet->song_id)->toArray());
         $user = App\Weixin_User::findOrFail($sheet->user_id)->toArray();
         $sheet->where('user_id', $sheet->user_id)->update(['name' => $user['user_nickname']]);
     });
 }
<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in 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::bind('songs', function ($slug) {
    return App\Song::whereSlug($slug)->first();
});
//Route::get('/','PagesController@index');
//Route::get('about','PagesController@about');
//Route::get('songs','SongsController@index');
//Route::get('songs/{song}','SongsController@show');
//Route::get('songs/{song}/edit','SongsController@edit');
//Route::patch('songs/{song}','SongsController@update');
$router->resource('songs', 'SongsController');
//Route::get('music',['as'=>'songs_path', 'uses'=>'SongsController@index']);
//Route::get('music/{song}',['as'=>'song_path', 'uses'=>'SongsController@show']);
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
Пример #3
0
| Application Routes
|--------------------------------------------------------------------------
|
| 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('/','PagesController@index');
//Route::get('about','PagesController@about');
//Route::get('/', function()
//{
//    return 'Home Page';
//});
Route::bind('song', function ($slug) {
    return App\Song::where('slug', $slug)->first();
});
//get('songs','SongsController@index');
//get('songs/{song}','SongsController@show');
//get('songs/{song}/edit','SongsController@edit');
//patch('songs/{song}','SongsController@update');
//get('employee',['as' => 'employee','uses' => 'EmployeeController@index']);
//get('employee/{id}',['as' => 'employeedetail','uses' => 'EmployeeController@index']);
Route::resource('employees', 'EmployeeController', ['names' => ['index' => 'employee', 'show' => 'employeedetail', 'edit' => 'employeeedit', 'create' => 'employeecreate', 'update' => 'employeeupdate', 'store' => 'employeestore', 'destroy' => 'employeedelete']]);
Route::post('projects/views/create', ['as' => 'projectsviewcreate', 'uses' => 'ProjectsController@create']);
Route::post('projects/views/edit', ['as' => 'projectsviewedit', 'uses' => 'ProjectsController@edit']);
Route::post('projects/views/predestroy', ['as' => 'projectsviewpredestroy', 'uses' => 'ProjectsController@predestroy']);
Route::post('projects/views/projectlist', ['as' => 'projectsviewlist', 'uses' => 'ProjectsController@projectlist']);
Route::get('projects', ['as' => 'projects', 'uses' => 'ProjectsController@index']);
Route::post('projects/store', ['as' => 'projectsstore', 'uses' => 'ProjectsController@store']);
Route::post('projects/update/{id}', ['as' => 'projectsupdate', 'uses' => 'ProjectsController@update']);