thiagousa

Experience

7,880

0 Best Reply Awards

  • Member Since 11 Months Ago
  • 77 Lessons Completed
  • 0 Favorites

12th October, 2018

thiagousa left a reply on Resource • 1 week ago

It's works.

public function postsDataTables()
{
    $datatable = DataTables::of(PostResources::collection(Post::all()))->toJson();
    
    return $datatable;
}

Exemplo in this link - https://github.com/thiagousa/datatable

thiagousa left a reply on Resource • 1 week ago

$posts = Post::with('user')->get();

return new PostCollection($posts);

11th October, 2018

thiagousa started a new conversation Resource • 1 week ago

I have two table, and i need to take just the name of all user for post.

8th October, 2018

thiagousa left a reply on Datatable - Laravel • 1 week ago

Document

    <h1>Table of Posts</h1>

    <div class="box-footer clearfix">
        <a href="{{ route('posts.create') }}"><button type="submit" class="btn btn-primary">Add New Post</button></a>
     </div>
     <hr>

    <table id="posts" class="table table-bordered">
        <thead>
            <tr>
                <th>Id</th>
                <th>Title</th>
                <th>created_at</th>
                <th>test</th>
                <th>action</th>
                      </tr>
        </thead>
    </table>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>  
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js"></script>
<script>
$(function() {
    $('#posts').DataTable({
        processing: true,
        serverSide: true,
        ajax: "{{ route('posts.datatables') }}",
            columns: [
            {data: 'id', name: 'id'},
            {data: 'title', name: 'title'},
            {data: 'created_at', name: 'created_at'},
            {data: 'test', name: 'test'},
            {data: 'action', name: 'action', orderable: false, searchable: false}
                      
            ],
    });
});
</script>

thiagousa started a new conversation Datatable - Laravel • 1 week ago

How can i do the buttons of my view doesn't use HTML in my Controller?

exemplo

public function postsDataTables() { $posts = Post::select(['id', 'title', 'created_at']);

    return Datatables::of($posts)
    ->addColumn('test', function ($post) {
        return $post->id;
    })
    ->addColumn('action', function ($post) {
        return '<a href="posts/'.$post->id.'/show" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> View </a> <a href="posts/'.$post->id.'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a> <a href="posts/'.$post->id.'/delete" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Delete</a>';
    })

    ->make(true);
}

4th January, 2018

thiagousa started a new conversation Redirection • 9 months ago

I have the fresh Laravel 5.5 with this screen.

Index of /blog2 [ICO] Name Last modified Size Description [PARENTDIR] Parent Directory - [DIR] app/ 2018-01-04 15:33 - [ ] artisan 2018-01-04 15:33 1.6K [DIR] bootstrap/ 2018-01-04 15:33 - [ ] composer.json 2018-01-04 15:33 1.4K [ ] composer.lock 2018-01-04 15:35 140K [DIR] config/ 2018-01-04 15:33 - [DIR] database/ 2018-01-04 15:33 - [ ] package.json 2018-01-04 15:33 1.1K [ ] phpunit.xml 2018-01-04 15:33 1.0K [DIR] public/ 2018-01-04 15:33 - [ ] readme.md 2018-01-04 15:33 3.5K [DIR] resources/ 2018-01-04 15:33 - [DIR] routes/ 2018-01-04 15:33 - [ ] server.php 2018-01-04 15:33 563 [DIR] storage/ 2018-01-04 15:33 - [DIR] tests/ 2018-01-04 15:33 - [DIR] vendor/ 2018-01-04 15:35 - [ ] webpack.mix.js 2018-01-04 15:33 549

I wanna redirection every for the public the Laravel index.php, I don't wanna nobody has to access to my frameworks files.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.