我正在尝试使绑定工作(遵循youtube上的教程).在这一点上,我基本上是复制粘贴代码; 它仍然没有用.
这是routes.php:
Route::model('song', 'App\Song');
Route::get('songs', 'SongsController@index');
Route::get('songs/{slug}', 'SongsController@show');
Route::get('songs/{slug}/edit', 'SongsController@edit');
Route::patch('songs/{slug}', 'SongsController@update');
Run Code Online (Sandbox Code Playgroud)
Song.php:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Song extends Eloquent {
protected $fillable = [
'title', 'lyrics'
];
}
Run Code Online (Sandbox Code Playgroud)
和SongsController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Song;
class SongsController extends Controller
{
public function index(Song $song) {
$songs = $song->get();
return view('songs.index', compact('songs'));
}
public function show(Song $song) {
return view('songs.show', compact('song'));
}
public function edit($slug) {
$song = …Run Code Online (Sandbox Code Playgroud)