Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesPong committed Jun 15, 2017
2 parents 7bad326 + f4edea9 commit 5f4ff67
Show file tree
Hide file tree
Showing 151 changed files with 3,019 additions and 708 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

YOUDAO_APP_KEY=
YOUDAO_APP_SECRET=
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ _ide_helper.php
/public/img
/public/plugins
/public/mix-manifest.json
/public/images
38 changes: 34 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,44 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Post publish and draft status
- Soft delete support of models

### Changed
- Dashboard panel text

### Fixed
- Post editor full screen bug

## 0.2.0 - 2017-06-15
### Added
- Backend
- Post publish status and draft status
- Soft delete support of models
- Active menu support
- Flash session in route redirection
- Function str_slug compitable with Chinese
- Frontend
- Materialize css support
- materialize pagination blade
- Multi widgets
- Home page
- Article detail page

### Changed
- Backend
- Use dismissible alert component in alerts partial
- Route name with prefix
- Auto-generated slug could be repeated bug
- Repository concrete with adding method scopeBoot
- Default post scope with published status
- Rename multi views name
- Repository Contract&Concrete with adding withCount method
- Post table columns
- Refactor assets folder structure

### Fixed
- Backend
- Post editor full screen bug
- Post missing input fields
- Password is not required in user-update action
- Repository delete bug

## 0.1.0 - 2017-05-29
### Added
Expand Down
11 changes: 9 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
- [ ] Wechat related
- [ ] Schedule(backup,stat,)
- [ ] I18N
- [ ] Highlight tab
- [ ] Links
- [ ] Settings
- [ ] File management
- [ ] Feature image
- [ ] Flash session

## Frontend

- [ ] Materialize css
- [x] Materialize css
- [ ] Search
- [ ] Websocket

Expand All @@ -25,4 +31,5 @@
- [ ] Refactor views with VueJs
- [ ] API
- [ ] Package
- [ ] Unit test
- [ ] Unit test
- [ ] Pjax
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/Traits/AuthRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ trait AuthRedirect
*/
protected function redirectTo()
{
return route('dashboard.index');
return route('admin.dashboard.index');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Backend/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function store(StoreUpdateCategoryRequest $request)
{
$category = $this->cateRepo->createCategory($request->all());

return redirect()->route('categories.index');
return redirect()->route('admin.categories.index')->withSuccess('Create category successfully!');
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public function update(StoreUpdateCategoryRequest $request, $id)
{
$category = $this->cateRepo->updateCategory($request->all(), $id);

return redirect()->route('categories.index');
return redirect()->route('admin.categories.index')->withSuccess('Update category successfully!');
}

/**
Expand All @@ -105,6 +105,6 @@ public function destroy($id)
{
$this->cateRepo->delete($id);

return redirect()->route('categories.index');
return redirect()->route('admin.categories.index')->withSuccess('Delete category successfully!');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Backend/PermissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function store(StoreUpdatePermissionRequest $request)
{
$perm = $this->permRepo->create($request->all());

return redirect()->route('permissions.index');
return redirect()->route('admin.permissions.index')->withSuccess('Create permission successfully!');
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public function update(StoreUpdatePermissionRequest $request, $id)
{
$perm = $this->permRepo->update($request->all(), $id);

return redirect()->route('permissions.index');
return redirect()->route('admin.permissions.index')->withSuccess('Update permission successfully!');
}

/**
Expand All @@ -105,6 +105,6 @@ public function destroy($id)
{
$this->permRepo->delete($id);

return redirect()->route('permissions.index');
return redirect()->route('admin.permissions.index')->withSuccess('Delete permission successfully!');
}
}
40 changes: 32 additions & 8 deletions app/Http/Controllers/Backend/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ public function __construct(PostRepository $postRepo, CategoryRepository $cateRe

/**
* Display a listing of the resource.
*
* @param Request $request
* @return \Illuminate\Http\Response
*/
public function index()
public function index(Request $request)
{
if ($request->has('trash')) {
$this->postRepo = $this->postRepo->onlyTrashed();
}

$posts = $this->postRepo->with(['category', 'author'])->paginate();

return view('admin.posts.index', compact('posts'));
Expand Down Expand Up @@ -76,7 +80,7 @@ public function store(StoreUpdatePostRequest $request)
{
$this->postRepo->createPost($request->all());

return redirect()->route('posts.index');
return redirect()->route('admin.posts.index')->withSuccess('Create post successfully!');
}

/**
Expand All @@ -100,13 +104,11 @@ public function show($id)
*/
public function edit($id)
{
$post = $this->postRepo->find($id);
$post = $this->postRepo->with('tags')->find($id);

$categories = $this->cateRepo->all();
$tags = $this->tagRepo->all();

$selected_tags = $this->postRepo->getTags($post);

return view('admin.posts.edit', compact('post', 'categories', 'tags', 'selected_tags'));
}

Expand All @@ -121,7 +123,7 @@ public function update(StoreUpdatePostRequest $request, $id)
{
$this->postRepo->updatePost($request->all(), $id);

return redirect()->route('posts.index');
return redirect()->route('admin.posts.index')->withSuccess('Update post successfully!');
}

/**
Expand All @@ -134,6 +136,28 @@ public function destroy($id)
{
$this->postRepo->delete($id);

return redirect()->route('posts.index');
return redirect()->route('admin.posts.index')->withSuccess('Move post to trash successfully!');
}

/**
* @param $id
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($id)
{
$this->postRepo->restore($id);

return redirect()->route('admin.posts.index')->withSuccess('Restore post successfully!');
}

/**
* @param $id
* @return \Illuminate\Http\RedirectResponse
*/
public function forceDelete($id)
{
$this->postRepo->forceDelete($id);

return redirect()->back()->withSuccess('Force delete post successfully!');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Backend/RoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function store(StoreUpdateRoleRequest $request)
{
$role = $this->roleRepo->createRole($request->all());

return redirect()->route('roles.index');
return redirect()->route('admin.roles.index')->withSuccess('Create role successfully!');
}

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public function update(StoreUpdateRoleRequest $request, $id)
{
$role = $this->roleRepo->updateRole($request->all(), $id);

return redirect()->route('roles.index');
return redirect()->route('admin.roles.index')->withSuccess('Update role successfully!');
}

/**
Expand All @@ -122,6 +122,6 @@ public function destroy($id)
{
$this->roleRepo->delete($id);

return redirect()->route('roles.index');
return redirect()->route('admin.roles.index')->withSuccess('Delete role successfully!');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Backend/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function store(StoreUpdateTagRequest $request)
{
$this->tagRepo->createTag($request->all());

return redirect()->route('tags.index');
return redirect()->route('admin.tags.index')->withSuccess('Create tag successfully!');
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public function update(StoreUpdateTagRequest $request, $id)
{
$this->tagRepo->updateTag($request->all(), $id);

return redirect()->route('tags.index');
return redirect()->route('admin.tags.index')->withSuccess('Update tag successfully!');
}

/**
Expand All @@ -105,6 +105,6 @@ public function destroy($id)
{
$this->tagRepo->delete($id);

return redirect()->route('tags.index');
return redirect()->route('admin.tags.index')->withSuccess('Delete tag successfully!');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function store(StoreUpdateUserRequest $request)
{
$this->userRepo->createUser($request->all());

return redirect()->route('users.index');
return redirect()->route('admin.users.index')->withSuccess('Create user successfully!');
}

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public function update(StoreUpdateUserRequest $request, $id)
{
$this->userRepo->updateUser($request->all(), $id);

return redirect()->route('users.index');
return redirect()->route('admin.users.index')->withSuccess('Update user successfully!');
}

/**
Expand All @@ -122,6 +122,6 @@ public function destroy($id)
{
$this->userRepo->delete($id);

return redirect()->route('users.index');
return redirect()->route('admin.users.index')->withSuccess('Delete user successfully!');
}
}
54 changes: 54 additions & 0 deletions app/Http/Controllers/Frontend/PostController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Http\Controllers\Frontend;

use App\Repositories\Contracts\PostRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class PostController extends Controller
{
/**
* @var PostRepository
*/
protected $postRepo;

/**
* PostController constructor.
* @param PostRepository $postRepo
*/
public function __construct(PostRepository $postRepo)
{
$this->postRepo = $postRepo;
}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// TODO paginate page should be dynamic set in config, e.g. config('app.post.perPage', 5)
$posts = $this->postRepo
->with(['category', 'tags', 'author'])
->paginate(5);

return view('posts.index', compact('posts'));
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$post = $this->postRepo
->with(['category', 'tags', 'author'])
->find($id);

return view('posts.show', compact('post'));
}
}
20 changes: 17 additions & 3 deletions app/Http/Requests/StoreUpdatePostRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public function authorize()
public function rules()
{
$rules = [
'title' => 'required|max:25',
'title' => 'required',
'description' => 'max:100',
'category_id' => 'required',
'category_id' => 'required|exists:categories,id',
'slug' => 'unique:posts',
'content' => 'required'
'content' => 'required',
'excerpt' => 'required',
'feature_img' => 'sometimes|required|url'
];

switch ($this->method()) {
Expand All @@ -44,4 +46,16 @@ public function rules()

return $rules;
}

/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
if (!$this->has('feature_img')) {
$this->replace($this->except('feature_img'));
}
}
}
Loading

0 comments on commit 5f4ff67

Please sign in to comment.