标签:color email pac provided desc out get page min
1就是文章分页展示
2就是详情
public function post(Post $post){//不过是$post
return view(config(‘theme.default.pages‘).‘.post‘)->withPost($post);
}
public function publish(Request $request, Post $post)
3从分类获取到分
$builder = $category->posts()->orderBy(‘posts.moderated_at‘, ‘DESC‘)->paginate( 10);
Api
1关系路由
Route::resource(‘posts.categories‘, ‘PostsCategoriesController‘, [‘only‘ => [‘index‘, ‘store‘, ‘destroy‘]]);
这个控制器是给我post添加分类的
$post->categories()->attach($request->get(‘categories’));//文章加分类
$post->categories()->sync($ids);
$post->categories()->detach($category);
CategoriesPostsController //分类下的文章
$category->posts()->paginate(10)
1创建文章的过程直接创建,直接修改关系,不是一起保存的
创建分类也是一样的直接创建,$category->name = hash(‘adler32‘, time());名字随机
2
$post->fill($request->all());$post->save();
3
Route::resource(‘categories‘, ‘CategoriesController‘, [‘except‘ => [‘create‘, ‘edit‘]]);
4改密码
public function update(Request $request)
{
//check that user has provided his current password
if($request->has(‘password‘) && Hash::check($request->get(‘password‘), $this->user->password)){//判断密码算法一样、、 password_verify($value, $hashedValue);、、password_verify — 验证密码是否和哈希匹配
$this->validate($request, [
‘email‘ => ‘email|max:255|unique:users,email,‘.$this->user->id,
‘username‘ => ‘max:50|unique:users,username,‘.$this->user->id,
‘name‘ => ‘max:255‘,
‘new_password‘ => ‘min:6|confirmed‘
]);
$this->user->fill($request->all());
if($request->get(‘new_password‘)){
$this->user->password = bcrypt($request->get(‘new_password‘));
}
$this->user->save();
标签:color email pac provided desc out get page min
原文地址:http://www.cnblogs.com/keiweila/p/7862884.html