laravel Route、Controller、Model、Migration初步
来源:互联网 发布:java视频教程谁的好 编辑:程序博客网 时间:2024/06/06 00:14
创建 Route:
/ routes / web.php
创建controller:
php artisan make:controller ArticleController
创建migration 建表:
php artisan make:migration create_articles_table --create=articles
创建Model:
php artisan make:model Article(也可以带目录例如: front / Article ,默认路径在 app\ )
路由设置:
Route::get(' / ' , function(){
return view(' / article / index');
});
Route::get( '/index' , 'ArticleController@articel_list' );
Route::get();
- Route::get('/article_list' , 'ArticleController@getArticleList');
- Route::post('/post','PostController@insert');
- Route::post('/App/http/controllers/post','PostController@update');
- Route::match(['get','post'], '/get', 'get@find');
- Route::any('/article/redirect','ArticleController@redirect');
- 路由带参数
- Route::get('/getFile/{id}',"getFile@gets");
- Route::get('/getFile/{id?}',"getFile@gets");
路由绑定:
Route::get('/getArticle/{ article }', 'ArticleController@getArticleContent' );
public function getArticleContent(Article $article )
{
$article->id ... ....
} //直接将对象带过去用
- 路由分组 group
profix 前缀
Route::group(['profix'=>'/posts'] , function(){
Route::get('/one' , 'post@one');
});
- 路由组中间件 进行过滤
Route::group(['middleware'=>'auth'], function(){
Route::get('/' , function(){ });
Route::get('/article', 'ArticleController@getArticle');
});
- 对路由参数的全局约束
http/provider /RouteServiceProvider.php
public function boot()
{
Route::pattern('id',[0-9]+);
parent::boot();
}
- 命名路由:
Route::get('/article_list','ArticleController@getArticleList')->name('articleList');
使用命名路由:
$url = route('articleList');
return redirect()->route('articleList'); ==== return redirect('/article_list');
- 命名空间 ['namespace'=>'Admin']
- 子域名路由 ['domain'=>'{account}.myapp.com)']
laravel-china 文档:
http://d.laravel-china.org/docs/5.4/routing
- 路由
get post put delete patch options
Restful 服务中 post put patch 区别
http://blog.csdn.net/iefreer/article/details/10414663
- laravel Route、Controller、Model、Migration初步
- laravel Route::controller 使用路由命名
- laravel 修改migration属性
- laravel(二)migration
- 我的Laravel学习之路之Route::resource和Form-Model-Binding,
- Laravel 5 Database Migration & Seeding
- Laravel 创建 migration 报错
- laravel 之数据迁移 migration
- Laravel- 使用migration 创建数据库
- Laravel的migration知识梳理
- laravel学习之Migration基础
- php laravel route
- laravel named route
- laravel Route 用法
- laravel route传递参数
- laravel 从route路由开始经过controller操作mysql数据库并返回结果显示在浏览器中 (select)
- Laravel 不能创建 migration 的问题
- Laravel 5如何安全删除migration文件
- 下拉框绑定数据字典只一级列表,非所有子节点
- 1. 当前时间转换为字符串格式2.jdbc.properties常用配置
- 算法学习笔记10-BFS宽度优先搜索
- 现在学习Java大数据还不晚
- window.opener用法
- laravel Route、Controller、Model、Migration初步
- JSON与XML相比优缺点
- ajax对服务器大气请求和接收返回信息
- 基础算法之“蒜头君采摘苹果”
- 流行编程语言的详细对比(7)--对象继承
- 如何关闭虚拟机的防火墙
- Cannot create PoolableConnectionFactory (ORA-28040: No matching authentication protocol
- web安全
- 微博web网站的授权流程