@RamjithAp, @Snapey, @divanoli Dear all collaborated with this thered see My comment box same to file attachment is is working fine.
comments/form.blade.php
@foreach ($task->project->comments as $comment)
<div>
<div><i class="fa fa-check-square-o"></i>
<span>{{ $comment->comments }} by
<span style="font-style: italic;color: #09f;">
{{ ($comment->user()->first()->username === auth()->user()->username) ? 'You' : $comment->user()->first()->username }}
</span>
</span></div>
<a href="/projects/{{ $task->project->id }}/comments/{{ $comment->id }}/edit">Edit</a>
<button class="btn btn-danger delete pull-right"
data-action="/projects/{{ $task->project->id }}/comments/{{ $comment->id }}"
data-token="{{csrf_token()}}">
<i class="fa fa-trash-o"></i>Delete
</button>
</div>
<hr/>
@endforeach
<form class="form-vertical" role="form" method="post" action="{{ route('projects.comments.create', ['projectId'=> $project->id, 'taskId'=>$task->id])}}">
<div class="form-group{{ $errors->has('comments') ? ' has-error' : '' }}">
<textarea name="comments" class="form-control" style="width:80%;" id="comment" rows="5" cols="5"></textarea>
@if ($errors->has('comments'))
<span class="help-block">{{ $errors->first('comments') }}</span>
@endif
</div>
<div class="form-group">
<button type="submit" class="btn btn-info">Add Comment</button>
</div>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
CommentController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\Comment;
use App\Task;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class CommentsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function postNewComment(Request $request, $id, Comment $comment,$taskId)
{
$this->validate($request, [
'comments' => 'required|min:5',
]);
$comment->comments = $request->input('comments');
$comment->project_id = $id;
$comment->user_id = Auth::user()->id;
$comment->task_id = $taskId;
$comment->save();
return redirect()->back()->with('info', 'Comment posted successfully');
}
}
routes
Route::post('projects/{projects}/tasks/{tasks}/comments', [
'uses' => 'CommentsController@postNewComment',
'as' => 'projects.comments.create',
'middleware' => ['auth']
]);
and include file
tasks/show.blade.php
<h2>{{$task->project->project_name}}</h2>
<hr>
{{$task->task_name}}
<hr>
{!!$task->body!!}
<hr>
@include('comments.form') // this is working fine
@include('files.form')
My comment include file is working fine but problem with file form. can you anybody guess the problem with file form