/home/mip/mip/app/Http/Controllers/Website/WebsiteController.php
<?php
namespace QxCMS\Http\Controllers\Website;
use QxCMS\Http\Controllers\Controller;
use QxCMS\Modules\Client\Repositories\Posts\PostsRepositoryInterface as Posts;
use QxCMS\Modules\Client\Repositories\JobOpening\JobOpeningRepositoryInterface as Job;
use QxCMS\Models\Countries as Country;
use Yajra\Datatables\Datatables;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use DB;
class WebsiteController extends Controller
{
protected $posts;
protected $job;
protected $country;
public function __construct(Posts $posts, Job $job, Country $country)
{
$this->posts = $posts;
$this->job = $job;
$this->country = $country;
}
public function datatable()
{
return view('datatable');
}
public function getJobs()
{
$job = $this->job->with('country')->select(['slug','position','country_id','opening_date','closing_date','status'])
->where([
['status','=','Open'],
['opening_date','<=', DB::raw('CURDATE()')],
['closing_date','>', DB::raw('CURDATE()')]
]);
return Datatables::of($job)
->addColumn('country_name', function($job){
return ucwords(strtolower($job->country->name));
})
->addColumn('action', function ($job) {
return '<a href="'.$job->slug.'" class="btn btn-xs btn-datatable"><i class="glyphicon glyphicon-search"></i> View Details</a>';
})
->editColumn('slug', '{{$slug}}')
->make(true);
// return DataTables::of(User::query())->make(true);
}
}