dimanche 10 septembre 2017

how to show comment table data in Laravel 5.2

i am developing project management app in laravel. in My app one project have many tasks and one task have comment box to users. I am developing comments post file and it is saving comments to comment table. comment/form.blade.php

<div class="row" style="margin-left:5px;padding:5px;">
    @if(isset($comments))
           @foreach( $comments as $comment)
                <div>
                    <div><i class="fa fa-check-square-o"></i>
                    <span> by
                       <span style="font-style: italic;color: #09f;">
                        
                       </span>
                    </span></div>
                    <a href="/projects//comments//edit">Edit</a>
                    <button class="btn btn-danger delete pull-right"
                      data-action="/projects//comments/"
                      data-token="">
                    <i class="fa fa-trash-o"></i>Delete
                    </button>
                </div>
                <hr/>

           @endforeach
    @endif

    <form class="form-vertical" role="form" method="post" action="">
        <div class="form-group">
            <textarea name="comments" class="form-control" style="width:80%;" id="comment" rows="5" cols="5"></textarea>
            @if ($errors->has('comments'))
                <span class="help-block"></span>
            @endif
        </div>

        <div class="form-group">
            <button type="submit" class="btn btn-info">Add Comment</button>
        </div>
        <input type="hidden" name="_token" value="">
    </form>
</div>  

I have include above blade file to show.blade.php file in tasks folder in view file task/show.blade.php

<h2></h2>
<hr>

<hr>
{!!$tasks->body!!}
<hr>
@include('comments.form')

now I need show My comment table data on each project........... how can I do this? I have following function and where shoud I put them?

 public function getTasks($id)
    {
        $tasks =  Task::project($id)->get();
        return $tasks;
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire