【问题标题】:Controller RESTful methods in laravel 5laravel 5 中的控制器 RESTful 方法
【发布时间】:2016-07-06 01:57:11
【问题描述】:

当我在 laravel 5 中执行 php artisan make:controller Test 命令时 我正在低于蓝图

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class Test extends Controller
{
    //
}

但文档说我们应该使用 RESTful 方法获得骨架

 class Test extends BaseController {

/**
 * Display a listing of the resource.
 *
 * @return Response
 */
public function index()
{
    //
}

/**
 * Show the form for creating a new resource.
 *
 * @return Response
 */
public function create()
{
    //
}

/**
 * Store a newly created resource in storage.
 *
 * @return Response
 */
public function store()
{
    //
}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return Response
 */
public function show($id)
{
    //
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return Response
 */
public function edit($id)
{
    //
}

/**
 * Update the specified resource in storage.
 *
 * @param  int  $id
 * @return Response
 */
public function update($id)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return Response
 */
public function destroy($id)
{
    //
}

}

那么在我的情况下有什么问题。如何获得 RESTful 资源控制器应该是什么?

【问题讨论】:

    标签: laravel-5


    【解决方案1】:

    我认为您必须在此命令末尾添加 --resource 选项才能生成 RESTful 控制器。在official laravel docs之后,你的命令应该是这样的:

    php artisan make:controller Test --resource
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-29
      • 2016-05-21
      • 1970-01-01
      • 2015-08-02
      • 2015-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多