小编Naj*_*ouk的帖子

邮递员 404 未找到

我是 laravel API 的初学者,我想显示文章列表(方法索引),我已经创建了模型文章,但我不能。

你好,我是 laravel API 的初学者,我想显示文章列表(方法索引),我已经创建了模型文章,但我不能。

文章控制器

<?php  
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Article;
use App\Http\Resources\Article as ArticleResource;

class ArticleController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $articles= Article::paginate(15);
        return ArticleResource::collection($articles);
    }
Run Code Online (Sandbox Code Playgroud)

创建表文章

 public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('body');
            $table->timestamps();
        });
    }
Run Code Online (Sandbox Code Playgroud)

应用服务提供者.php

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
    /**
     * …
Run Code Online (Sandbox Code Playgroud)

laravel postman

0
推荐指数
1
解决办法
2317
查看次数

标签 统计

laravel ×1

postman ×1