/home/mip/mip/app/Modules/Client/Controllers/Posts/PostCategoryController.php
<?php

namespace QxCMS\Modules\Client\Controllers\Posts;

use Illuminate\Http\Request;
use QxCMS\Http\Controllers\Controller;
use Datatables;

use QxCMS\Modules\Client\Repositories\Posts\PostCategoryRepositoryInterface as PostCategory;

class PostCategoryController extends Controller
{

    public function __construct(PostCategory $postCategory)
    {
        $this->postCategory = $postCategory;
    }

    public function store(Request $request)
    {        
        return $this->postCategory->create($request->all());
    }

    public function update(Request $request)
    {
        return $this->postCategory->update($request);
    }

    public function destroy($id)
    {
        return $this->postCategory->delete($id); 
    }

    public function getPostCategoryData()
    {
        $postCategory = $this->postCategory->select(['*']);
        return Datatables::of($postCategory)
           ->addColumn('action', function($postCategory) {
                $html = '<a href="#edit" class="btn btn-xs btn-flat btn-warning btn-edit" data-id="'.$postCategory->id.'">
                        <i class="fa fa-pencil"></i>
                    </a>
                    <a href="#delete" class="btn btn-xs btn-flat btn-danger btn-delete" data-action="'.url('client').'/modals/postcategory/destroy/'.$postCategory->id.'" data-id="'.$postCategory->id.'">
                    <i class="fa fa-trash-o"></i>
                    </a>';
            return $html;
            })->make(true);
    }
}