我有表格:class Tag extends Model
{
protected $fillable = [
'name',
];
protected $dates = [
'created_at',
'updated_at',
];
public function Posts()
{
return $this->morphedByMany(Post::class, 'taggable');
}
}
我有模特:
标签
class TagController extends Controller
{
public function show(Tag $Tag)
{
return Response::json($Tag);
}
}
我有标签控制器:
Route::group(['namespace' => 'Tags', 'prefix' => 'tags'], function () {
Route::get('/{tags}', 'TagController@show');
Route::delete('/{tags}', 'TagController@destroy')->middleware('auth:api');
});
我有溃败:
path is not absolute: D:\xyz.csv
我尝试使用id获取标记,但它不起作用。我做错了什么或遗忘定义了什么?
答案 0 :(得分:0)
控制器应该是这样的:
use App\Tag;
class TagController extends Controller
{
public function show($tag)
{
return Response::json(Tag::find($tag));
}
}
路线:
Route::group(['namespace' => 'tags', 'prefix' => 'tags'], function () {
Route::get('/{tag}', 'TagController@show');
Route::delete('/{tag}', 'TagController@destroy')->middleware('auth:api');
});