|
|
@ -3,6 +3,7 @@ |
|
|
namespace App\Http\Controllers\Projects; |
|
|
namespace App\Http\Controllers\Projects; |
|
|
|
|
|
|
|
|
use Illuminate\Http\Request; |
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
use App\Entities\Projects\Comment; |
|
|
use App\Entities\Projects\Project; |
|
|
use App\Entities\Projects\Project; |
|
|
use App\Http\Controllers\Controller; |
|
|
use App\Http\Controllers\Controller; |
|
|
|
|
|
|
|
|
@ -16,9 +17,14 @@ class CommentsController extends Controller |
|
|
*/ |
|
|
*/ |
|
|
public function index(Project $project) |
|
|
public function index(Project $project) |
|
|
{ |
|
|
{ |
|
|
|
|
|
$editableComment = null; |
|
|
$comments = $project->comments()->latest()->paginate(); |
|
|
$comments = $project->comments()->latest()->paginate(); |
|
|
|
|
|
|
|
|
return view('projects.comments', compact('project', 'comments')); |
|
|
|
|
|
|
|
|
if (request('action') == 'comment-edit' && request('comment_id') != null) { |
|
|
|
|
|
$editableComment = Comment::find(request('comment_id')); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return view('projects.comments', compact('project', 'comments', 'editableComment')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -34,8 +40,6 @@ class CommentsController extends Controller |
|
|
|
|
|
|
|
|
$newComment = $request->validate([ |
|
|
$newComment = $request->validate([ |
|
|
'body' => 'required|string|max:255', |
|
|
'body' => 'required|string|max:255', |
|
|
'fu_type_id' => 'nullable|numeric', |
|
|
|
|
|
'objection_id' => 'nullable|numeric', |
|
|
|
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
$project->comments()->create([ |
|
|
$project->comments()->create([ |
|
|
@ -47,4 +51,23 @@ class CommentsController extends Controller |
|
|
|
|
|
|
|
|
return back(); |
|
|
return back(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Update the specified comment. |
|
|
|
|
|
* |
|
|
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
|
|
* @param \App\Entities\Projects\Project $project |
|
|
|
|
|
* @param \App\Entities\Projects\Comment $comment |
|
|
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
*/ |
|
|
|
|
|
public function update(Request $request, Project $project, Comment $comment) |
|
|
|
|
|
{ |
|
|
|
|
|
$commentData = $request->validate([ |
|
|
|
|
|
'body' => 'required|string|max:255', |
|
|
|
|
|
]); |
|
|
|
|
|
$comment->update($commentData); |
|
|
|
|
|
flash(__('comment.updated'), 'success'); |
|
|
|
|
|
|
|
|
|
|
|
return redirect()->route('projects.comments.index', [$project] + request(['page'])); |
|
|
|
|
|
} |
|
|
} |
|
|
} |