美文网首页
天外天学习第5次作业

天外天学习第5次作业

作者: Hie_9e55 | 来源:发表于2017-11-04 23:28 被阅读0次

    写一个博客???
    不存在的
    把组长教的东西重复一遍???
    组长都教了什么?
    培训一结束我就忘记了
    我按手册学习一遍吧

    路由学习

    <?php//这是web.php
    
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
    
    Route::get('/', function () {
        return view('welcome');
    })->name('home');
    
    Route::group(['prefix'=>'/'] ,function(){
    
        Route::get('/{id}',function($id){
            return "id:" . $id;
        });
    
        Route::get('/{id}/{password}','MyController@showid');
    
    });
    
    <?php//这是自定义的中间件,已注册
    /**
     * Created by PhpStorm.
     * User: Dean Duo
     * Date: 2017/11/4
     * Time: 9:06
     */
    
    namespace App\Http\Middleware;
    
    use Closure;
    class MyMiddleware
    {
        /**
         * 处理传入的请求
         *
         * @param  \Illuminate\Http\Request  $request
         * @param  \Closure  $next
         * @return mixed
         */
        public function handle($request, Closure $next)
        {
            if ($request->id <= 200) {
                return redirect('/');
            }
    
            return $next($request);
        }
    
    }
    
    <?php自定义的控制层
    
    namespace App\Http\Controllers;
    
    use App\Http\Controllers;
    
    class MyController extends Controller
    {
        public function __construct(){
            $this->middleware('MyMiddleware');
        }
    
        public function showid($id ,$password){
            return view('welcome');
        }
    }
    
    image.png image.png
    <?php/这是数据迁移
    
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;
    
    class CreateUsersTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
        Schema::create('flights', function (Blueprint $table) {
                $table->increments('id');
                $table->timestamps();
                $table->string('origin2');
                $table->string('destination2');
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::dropIfExists('users');
        }
    }

    相关文章

      网友评论

          本文标题:天外天学习第5次作业

          本文链接:https://www.haomeiwen.com/subject/hfxfmxtx.html