吐槽一下 laravel
表单为空的时候,居然不能解析为 NULL,而是 update 成 empty 字段,这实在是无语。
需要在 model 中进行修正:
1 2 3 4 5 |
public function setUrlAttribute($value){ $this->attributes['url'] = $value ?:NULL; } |
SoftDelete 用起来也不方便,需要现在 Model 中声明:
1 2 3 4 5 6 7 |
use Illuminate\Database\Eloquent\SoftDeletes; class Sidebar extends Model { use SoftDeletes; protected $dates = ['deleted_at']; .... |
用 where() 方法,返回 array 要加 get(),find() 就不用,什么时候要加 get() 什么时候不用我现在还是分不太清。
[…] strstr 函数还有个坑,如果第二个参数 $item->url 是 empty 会报错,NULL 不会报错,Laravel 中 NULL 跟 empty 的坑参见这个帖子。 […]