随笔分类 -  Laravel

摘要:借鉴:http://www.cnblogs.com/wish123/p/4756669.html Laravel所有请求的入口文件是:/public/index.php,代码如下 (1)自动加载文件 自动加载文件功能是通过Composer实现的,在composer.json中设置的加载方式里提取加载 阅读全文
posted @ 2016-06-29 17:51 林锅 阅读(1984) 评论(0) 推荐(0) 编辑
摘要:laravel自带了auth类和User模型来帮助我们很方便的实现用户登陆、判断。 首先,先配置一下相关参数 app/config/auth.php: model 指定模型 table 指定用户表 protected $table = 'user'; model 指定模型 table 指定用户表 p 阅读全文
posted @ 2016-06-24 10:36 林锅 阅读(1563) 评论(0) 推荐(0) 编辑
摘要:根据 Laravel 4.x 和 5.0 的经验, 只需要到 config/app.php 中设置下 'timezone' 参数为 'PRC' 就好了, 找到 Lumen 的 config 目录, 在 /vendor/laravel/lumen-framework/config 路径下, 但是 co 阅读全文
posted @ 2016-06-15 10:02 林锅 阅读(3663) 评论(0) 推荐(0) 编辑
摘要:在用laravel框架来获取数据,若数据不存在时,以为会返回空,其实不是的,其实是一个 collection 值,会返回如下: 当 $result 为空时,empty($result) 是不为false的,还是有值的,如上,因此要用 count($result) 来验证;或者修改获取语句,改为 则会 阅读全文
posted @ 2016-04-27 17:47 林锅 阅读(1905) 评论(0) 推荐(0) 编辑
摘要:1、权限是否有设置为777; 2、app key是否有设置; 3、apache下是否有开启重写,a2enmod; 4、nginx下server的location是否配置正确,重写规则有没添加,route的路由有没有写全,即"xxx/public/xxx"; 阅读全文
posted @ 2016-04-18 16:37 林锅 阅读(2685) 评论(0) 推荐(0) 编辑
摘要:Laravel 的数据库操作基于 Eloquent ORM,在插入数据时有以下几种方式,返回结果也不会不同: 1、insert 插入后会返回 true or false; 2、create 插入成功后会返回插入的数据元; 3、firstOrCreate 插入成功后会返回插入的数据元,不过若存在时间戳 阅读全文
posted @ 2016-02-17 14:06 林锅 阅读(3799) 评论(0) 推荐(0) 编辑
摘要:在项目中使用 laravel 的 cache 时,使用下面形式方法: 但是,发现如果获取的数据为空或者不返回数据,它也照样存储,消耗内存,因此换成了先校验是否存在再保存的形式。 同时,Cache::tags 的用法是以一系列 tag 作为 cache 的键在内存中存储的,所以当把其中某个 tag 换 阅读全文
posted @ 2016-01-15 12:31 林锅 阅读(923) 评论(0) 推荐(0) 编辑
摘要:这两天通过对Cookie和Session的查找和了解,网上关于它们两个的基础知识点都是差不多的,也收藏了几篇不错的博客,同时自己做了些实验后,有了以下几点了解: 1、setcookie 这里有三个地方需注意: (1)expire 是指 cookie 的有效期,之前跟 cookie 的属性 maxAg 阅读全文
posted @ 2016-01-07 14:35 林锅 阅读(686) 评论(0) 推荐(0) 编辑
摘要:转自:http://www.tuicool.com/articles/2u2mmmuPost data using ajax in laravel 5 to controllerIf you are going to work with ajax data post to controller or... 阅读全文
posted @ 2015-08-12 15:09 林锅 阅读(412) 评论(0) 推荐(0) 编辑
摘要:1、在laravel的Eloquent ORM中,默认表会有created_at、updated_at两个字段,因此在使用create函数时若表无这两个字段会出错,可以设置 2、使用create跟 $fillable 的设置有关,若某些字段不能加入数组,其余尽量将表的字段写入,某些字段有默认值的可不 阅读全文
posted @ 2015-07-21 11:44 林锅 阅读(7288) 评论(0) 推荐(0) 编辑
摘要:laravel的事务使用如下:DB::connection('gvideo')->transaction(function () use ($user_id, $video_id, $action_id) { $this->create(array('user_id' ... 阅读全文
posted @ 2015-07-21 11:38 林锅 阅读(420) 评论(0) 推荐(0) 编辑
摘要:1. Composer 安装编辑 composer.json 文件, require 节点下增加:"illuminate/html": "~5.0"然后composer install2. 添加 providers修改 config/app.php 文件, 在 providers 数组里面添加:'I... 阅读全文
posted @ 2015-07-21 11:34 林锅 阅读(840) 评论(0) 推荐(0) 编辑
摘要:[PDOException] SQLSTATE[28000] [1045] Access denied for user ‘homestead’@’localhost’ (using password: YES) looks like same error different is not show... 阅读全文
posted @ 2015-07-09 14:00 林锅 阅读(2982) 评论(0) 推荐(0) 编辑
摘要:当第一次使用cache时,想用 memcached 的方式,但是它直接报错:说明你的php没安装 memcached 这个扩展,在ubuntu下直接 sudo apt-get install memcached 就可以了 (http://uixor.iteye.com/blog/1103014)再重... 阅读全文
posted @ 2015-03-16 10:58 林锅 阅读(858) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://github.com/liebig/cron感觉Cron只是帮你将很多需要定时执行的任务都归结在一个方法中,并且各自设定不同的时间,比较统一方便,但是在外部还是需要操作linux的crontab指令,将任务执行的代码写入,使得外部定时去run Cron。linux的cron... 阅读全文
posted @ 2015-01-14 15:53 林锅 阅读(770) 评论(0) 推荐(0) 编辑
摘要:原文安装链接:https://github.com/Maatwebsite/Laravel-Excel代码如下: 1 if ($rows = DB::connection('glist')->table('program_view')->where('v_type', $type)-... 阅读全文
posted @ 2015-01-14 14:56 林锅 阅读(2663) 评论(0) 推荐(0) 编辑
摘要:安装完laravel项目后,开启了重写,/app/storage也设置好了权限,但是始终无法显示出页面,并出现: "Whoops, looks like something went wrong."将/app/config/app的debug设置为true后,出现如下错误: production... 阅读全文
posted @ 2014-11-13 17:05 林锅 阅读(587) 评论(0) 推荐(0) 编辑
摘要:在github上有laravel项目的debugbar,可以查看项目的页面引用、变量、数据库使用、内存和反应时间等,貌似是一个还不错的小工具,效果如下:安装地址:https://github.com/barryvdh/laravel-debugbar所有的安装命令都在项目的根文件夹下输入,安装到第四... 阅读全文
posted @ 2014-10-21 15:15 林锅 阅读(2573) 评论(0) 推荐(0) 编辑
摘要:在Laravel中已经有内置了发送邮件的功能,通过 Mail::send 可发送邮件,但要使用这个函数必须先进行相关配置。 在 /app/config/mail.php 中设置你的邮件参数,如下: 1 1 'smtp', 18 18 19 19 /* 20 20 ... 阅读全文
posted @ 2014-10-18 10:03 林锅 阅读(2908) 评论(0) 推荐(0) 编辑
摘要:当通过命令行:php artisan migrate:make create_authors_table --table=authors --create时,在 migration.php 中若Schema::table()而不是Schema::create时,会出现 table 不存在的指示,这时... 阅读全文
posted @ 2014-10-17 14:52 林锅 阅读(487) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示