文章分类 -  &Laravel

摘要:php artisan route:cache php artisan route:clear php artisan route:list 如果你的应用只用到了基于控制器的路由,那么你应该充分利用 Laravel 的路由缓存。使用路由缓存将极大地减少注册全部应用路由的时间。某些情况下,路由注册甚至 阅读全文
posted @ 2017-08-27 19:23 silvercell 阅读(1543) 评论(0) 推荐(0) 编辑
摘要:位置: app\Http\Controllers ... ... 单一操作控制器: class ShowFile / public function __invoke() Route::get('/show' ,'ShowFile', ); 为单一操作控制器注册路由时,无需指定方法: 中间件: Ro 阅读全文
posted @ 2017-08-27 18:58 silvercell 阅读(2114) 评论(0) 推荐(0) 编辑
摘要:开发文章类网站核心是文章类 文章模块。完成一个模块的过程。 核心到周边 文章 -> 用户 -> 用户评论文章 -> 点赞 -> 个人中心 等 ... ... 过程: 编写控制器方法: - design logic -> c? r? u? d? 分析操作 编写控制器方法: - design logic 阅读全文
posted @ 2017-08-27 11:27 silvercell 阅读(1227) 评论(0) 推荐(0) 编辑
摘要:问题: 在laravel项目中,使用PHP artisan make:migration xxx 创建了数据库迁移文件,测试时手动删除了该迁移文件就会报错: [ErrorException] include(D:\projects\lav53\vendor\composer/../../databa 阅读全文
posted @ 2017-08-26 11:00 silvercell 阅读(1074) 评论(0) 推荐(0) 编辑
摘要:文章列表页 评论数 $post = App\Post::withCount('comments')->get(); 模型关联计数 {{$post->comments_count}} public function getArticleList() { $ar... 阅读全文
posted @ 2017-08-22 12:38 silvercell 阅读(3195) 评论(0) 推荐(0) 编辑
摘要:添加评论业务逻辑: (!!!不建议!!!) 直接在在模板中使用: {{$post->comments as $ comment}} @foreach($post->comments as $comment) {{$comments->created... 阅读全文
posted @ 2017-08-22 12:36 silvercell 阅读(1628) 评论(0) 推荐(0) 编辑
摘要:comment 评论通过模型关联添加 post_id 添加到写入的关联模型中 阅读全文
posted @ 2017-08-22 12:36 silvercell 阅读(1703) 评论(0) 推荐(0) 编辑
摘要:laravel 手册 ORM 模型 阅读全文
posted @ 2017-08-21 23:06 silvercell 阅读(1654) 评论(0) 推荐(0) 编辑
摘要:添加user_id 到文章添加的方法中 将当前登录用户展示到模板上 将用文章作者 通过关联的方式 查出来循环到模板中 Policy 权限控制的使用: 定义策略类 php artisan make:policy PostPolicy 注册策略类 并 关联模型 public function updat 阅读全文
posted @ 2017-08-21 22:30 silvercell 阅读(2589) 评论(0) 推荐(0) 编辑
摘要:注册逻辑中: 密码和重复密码的验证 提交注册表中有一个 password ,一个password_confirmation 两个字段,进行提交。在进行表单 validate 中直接进行 confirmed 条件进行验证 用将请求用request() 接受传来的参数并进行验证 注册的基本步骤: 用户祖 阅读全文
posted @ 2017-08-21 16:08 silvercell 阅读(1491) 评论(0) 推荐(0) 编辑
摘要:return back(); // 跳转到上一页 return redirect(' /posts/{$post->id} '); // 重定向方法 return redirect('/post'); // 路由的方法 阅读全文
posted @ 2017-08-21 13:45 silvercell 阅读(3118) 评论(0) 推荐(0) 编辑
摘要:第三方的js 插件使用肯定先要进行引入,然后按照文档规划目录将 js css font .... 要依赖的文件导入到文件夹 然后根据 文档进行生成一个 demo 在文本编辑器中取出来时候很可能要将标签和内容原样输出: {!! str_limit($post->content, 1200, '... 阅读全文
posted @ 2017-08-21 11:48 silvercell 阅读(1545) 评论(0) 推荐(0) 编辑
摘要:错误处理数错误, count() 阅读全文
posted @ 2017-08-21 10:42 silvercell 阅读(2123) 评论(0) 推荐(0) 编辑
摘要:在控制器中写 , 验证传来的数据是否合法: 自定义验证错误提示信息 将所有提示信息改成中文 将翻译文件新建文件夹 zh 放在 resources/lang/ config/app.php -> locale =>'en' 改成 'zh' 则提示中文的错误信息 翻译包: 阅读全文
posted @ 2017-08-21 10:35 silvercell 阅读(1014) 评论(0) 推荐(0) 编辑
摘要:开发应用思路: ·· 业务逻辑: 阅读全文
posted @ 2017-08-21 08:54 silvercell 阅读(1176) 评论(0) 推荐(0) 编辑
摘要:$post = .... ->paginate(4); in post.blade.php {{$post->links()}} 阅读全文
posted @ 2017-08-21 00:30 silvercell 阅读(1462) 评论(0) 推荐(0) 编辑
摘要:字符串截取 {{ str_limit($posts->content, 120, '... ... ') }} 阅读全文
posted @ 2017-08-21 00:28 silvercell 阅读(8318) 评论(0) 推荐(0) 编辑
摘要:php artisan tinker tinker 中执行 github: 参考文档: https://github.com/fzaninotto/Faker 阅读全文
posted @ 2017-08-21 00:11 silvercell 阅读(2195) 评论(0) 推荐(0) 编辑
摘要:建 Model 更改对应表的方法: model 中: protected $table = ""; 屏了时间: protected $timestamps = false; `timestamps 时间不对,进行更改 tinker 的使用 测试 model 方法 php artisan tinker 阅读全文
posted @ 2017-08-20 23:51 silvercell 阅读(1778) 评论(0) 推荐(0) 编辑
摘要:存的 timestamps -> 取出来想转成可视 例如: 2017 8 May $post->created_at->toFormattedDateString(); doc: http://carbon.nesbot.com/docs/ 阅读全文
posted @ 2017-08-20 23:21 silvercell 阅读(4365) 评论(0) 推荐(0) 编辑