Skip to content

Commit

Permalink
Merge pull request #1 from Laralum/analysis-87k903
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
24aitor authored Apr 15, 2017
2 parents 47d471d + 62466b4 commit 33d9d6a
Show file tree
Hide file tree
Showing 27 changed files with 752 additions and 724 deletions.
33 changes: 20 additions & 13 deletions src/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Laralum\Forum\Models\Category;
use Laralum\Forum\Models\Thread;
use Laralum\Forum\Models\Comment;

class CategoryController extends Controller
{
Expand All @@ -20,6 +18,7 @@ public function index()
$this->authorize('view', Category::class);

$categories = Category::all();

return view('laralum_forum::laralum.categories.index', ['categories' => $categories]);
}

Expand All @@ -38,7 +37,8 @@ public function create()
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
Expand All @@ -50,14 +50,16 @@ public function store(Request $request)
]);

Category::create($request->all());

return redirect()->route('laralum::forum.categories.index')
->with('success', __('laralum_forum::general.category_added'));
}

/**
* Display the specified resource.
*
* @param \Laralum\Forum\Models\Category $category
* @param \Laralum\Forum\Models\Category $category
*
* @return \Illuminate\Http\Response
*/
public function show(Category $category)
Expand All @@ -70,7 +72,8 @@ public function show(Category $category)
/**
* Show the form for editing the specified resource.
*
* @param \Laralum\Forum\Models\Category $category
* @param \Laralum\Forum\Models\Category $category
*
* @return \Illuminate\Http\Response
*/
public function edit(Category $category)
Expand All @@ -83,8 +86,9 @@ public function edit(Category $category)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Category $category
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Category $category
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Category $category)
Expand All @@ -95,38 +99,41 @@ public function update(Request $request, Category $category)
'name' => 'required|max:255',
]);
$category->update($request->all());

return redirect()->route('laralum::forum.categories.index')
->with('success', __('laralum_forum::general.category_updated',['id' => $category->id]));
->with('success', __('laralum_forum::general.category_updated', ['id' => $category->id]));
}

/**
* Remove the specified resource from storage.
*
* @param \Laralum\Forum\Models\Category $category
* @param \Laralum\Forum\Models\Category $category
*
* @return \Illuminate\Http\Response
*/
public function confirmDestroy(Category $category)
{
$this->authorize('delete', $category);

return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'method' => 'DELETE',
'message' => __('laralum_forum::general.sure_del_category', ['category' => $category->name]),
'action' => route('laralum::forum.categories.destroy', ['category' => $category->id]),
'action' => route('laralum::forum.categories.destroy', ['category' => $category->id]),
]);
}

/**
* Remove the specified resource from storage.
*
* @param \Laralum\Forum\Models\Category $category
* @param \Laralum\Forum\Models\Category $category
*
* @return \Illuminate\Http\Response
*/
public function destroy(Category $category)
{
$this->authorize('delete', $category);

$category->threads->each(function($thread) {
$category->threads->each(function ($thread) {
$thread->update(['category_id' => Category::first()->id]);
});

Expand Down
31 changes: 15 additions & 16 deletions src/Controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Laralum\Forum\Models\Thread;
use Laralum\Forum\Models\Comment;
use Illuminate\Support\Facades\Auth;
use Laralum\Forum\Models\Comment;
use Laralum\Forum\Models\Thread;

class CommentController extends Controller
{

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Thread $thread
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Thread $thread
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -28,9 +27,9 @@ public function store(Request $request, Thread $thread)
]);

Comment::create([
'user_id' => Auth::id(),
'user_id' => Auth::id(),
'thread_id' => $thread->id,
'comment' => $request->comment,
'comment' => $request->comment,
]);

return redirect()->route('laralum::forum.threads.show', ['thread' => $thread->id])
Expand All @@ -40,8 +39,8 @@ public function store(Request $request, Thread $thread)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Comment $comment
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Comment $comment
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -54,18 +53,17 @@ public function update(Request $request, Comment $comment)
]);

$comment->update([
'comment' => $request->comment
'comment' => $request->comment,
]);

return redirect()->route('laralum::forum.threads.show', ['thread' => $comment->thread->id])->with('success', __('laralum_forum::general.comment_updated', ['id' => $comment->id]));

}

/**
* confirm destroy of the specified resource from storage.
*
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Comment $comment
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Comment $comment
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -74,16 +72,16 @@ public function confirmDestroy(Request $request, Comment $comment)
$this->authorize('delete', $comment);

return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'method' => 'DELETE',
'message' => __('laralum_forum::general.sure_del_comment', ['comment' => $comment->comment]),
'action' => route('laralum::forum.comments.destroy', ['comment' => $comment->id]),
'action' => route('laralum::forum.comments.destroy', ['comment' => $comment->id]),
]);
}

/**
* Remove the specified resource from storage.
*
* @param \Laralum\Forum\Models\Comment $comment
* @param \Laralum\Forum\Models\Comment $comment
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -92,6 +90,7 @@ public function destroy(Comment $comment)
$this->authorize('delete', $comment);

$comment->delete();

return redirect()->route('laralum::forum.threads.show', ['category' => $comment->thread->id])->with('success', __('laralum_forum::general.comment_deleted', ['id' => $comment->id]));
}
}
8 changes: 3 additions & 5 deletions src/Controllers/PublicCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
namespace Laralum\Forum\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Laralum\Forum\Models\Category;
use Laralum\Forum\Models\Thread;
use Laralum\Forum\Models\Comment;

class PublicCategoryController extends Controller
{
Expand All @@ -18,14 +15,15 @@ class PublicCategoryController extends Controller
public function index()
{
$categories = Category::all();

return view('laralum_forum::public.categories.index', ['categories' => $categories]);
}


/**
* Display the specified resource.
*
* @param \Laralum\Forum\Models\Category $category
* @param \Laralum\Forum\Models\Category $category
*
* @return \Illuminate\Http\Response
*/
public function show(Category $category)
Expand Down
23 changes: 11 additions & 12 deletions src/Controllers/PublicCommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Laralum\Forum\Models\Category;
use Laralum\Forum\Models\Thread;
use Laralum\Forum\Models\Comment;
use Illuminate\Support\Facades\Auth;
use Laralum\Forum\Models\Comment;
use Laralum\Forum\Models\Thread;

class PublicCommentController extends Controller
{

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Thread $thread
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Thread $thread
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -29,9 +27,9 @@ public function store(Request $request, Thread $thread)
]);

Comment::create([
'user_id' => Auth::id(),
'user_id' => Auth::id(),
'thread_id' => $thread->id,
'comment' => $request->comment,
'comment' => $request->comment,
]);

return redirect()->route('laralum_public::forum.threads.show', ['thread' => $thread->id])
Expand All @@ -41,8 +39,8 @@ public function store(Request $request, Thread $thread)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Comment $comment
* @param \Illuminate\Http\Request $request
* @param \Laralum\Forum\Models\Comment $comment
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -55,7 +53,7 @@ public function update(Request $request, Comment $comment)
]);

$comment->update([
'comment' => $request->comment
'comment' => $request->comment,
]);

return redirect()->route('laralum_public::forum.threads.show', ['thread' => $comment->thread->id])
Expand All @@ -65,7 +63,7 @@ public function update(Request $request, Comment $comment)
/**
* Remove the specified resource from storage.
*
* @param \Laralum\Forum\Models\Comment $comment
* @param \Laralum\Forum\Models\Comment $comment
*
* @return \Illuminate\Http\Response
*/
Expand All @@ -74,6 +72,7 @@ public function destroy(Comment $comment)
$this->authorize('publicDelete', $comment);

$comment->delete();

return redirect()->route('laralum_public::forum.threads.show', ['thread' => $comment->thread->id])
->with('success', __('laralum_forum::general.comment_deleted', ['id' => $comment->id]));
}
Expand Down
Loading

0 comments on commit 33d9d6a

Please sign in to comment.