写一个博客???
不存在的
把组长教的东西重复一遍???
组长都教了什么?
培训一结束我就忘记了
我按手册学习一遍吧
路由学习
<?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');
}
}
网友评论