0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

laravelでの静的ページカンタン生成

Posted at
route/web.php
//必ず最後にかくこと
Route::get('{code}', 'PageController@page');
contoller
<?php

namespace App\Http\Controllers;

use View;

class PageController extends Controller
{

 /**
   *静的ページ系
   *
   * @return \Illuminate\Http\Response
   */
    public function page($code)
    {
        if(View::exists('page.'.$code) ){Q
            return view('page.'.$code);  
        }
        abort(404);
        
    }
}

こうすることで以降resources/views/pageに該当のview(ex:/companyみたいなurlにしたいならcompany.blade.php)を入れるだけで
ページの追加が可能となる
web.phpの追加すら不要

0
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?