先来个加密解密:
Crypt::encrypt($request->secret)
Crypt::decrypt($encryptedValue);
Hash 单向加密/判断:
Hash::make($request->newPassword)
Hash::check('plain-text', $hashedPassword)
辅助函数:
数组/路径/字符串/URL/其它
$array = array_add(['name' => 'Desk'], 'price', 100);
$array = array_collapse([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
list($keys, $values) = array_divide(['name' => 'Desk']);
$array = array_dot(['foo' => ['bar' => 'baz']]);
$array = array_except($array, ['price']);
$array = ['name' => 'Desk', 'price' => 100];
$array = [100, 200, 300];
$value = array_first($array, function ($key, $value) {
return $value >= 150;});
$value = array_first($array, $callback, $default);
$array = ['name' => 'Joe', 'languages' => ['PHP', 'Ruby']];
$array = array_flatten($array);
$array = ['products' => ['desk' => ['price' => 100]]];
array_forget($array, 'products.desk');
$array = ['products' => ['desk' => ['price' => 100]]];
$value = array_get($array, 'products.desk');
$array = ['products' => ['desk' => ['price' => 100]]];
$hasDesk = array_has($array, ['products.desk']);
分页用法:
$users = DB::table('users')->paginate(15);
如果仅仅想显示上一页、下一页这样简单的分页的话,就选择。
$users = DB::table('users')->simplePaginate(15);
view 里面显示分页:
{!!$users->render()!!}
辅助情况:
$result->count();
$result->currentPage()
$result->hasMorePages()
$result->lastPage()
$result->nextPageUrl()
$result->perPage()
$result->previousPageUrl()
$result->total()
$result->url($page)
Redis使用:
php初学者-千锋php课程笔记