CasperSecurity
<?php
namespace App\Http\Livewire\Report;
use App\Models\ManageProject;
use App\Models\Organisation;
use Carbon\Carbon;
use Livewire\Component;
class ProjectReportLivewire extends Component
{
public $search;
public $perPage = 10;
public $orderBy = 'id';
public $orderAsc = 'asc';
public function closemodalclick()
{
$this->resetValidation();
$this->datatable = [];
}
public function mount()
{
$this->from_date = Carbon::now()->format('Y-m-d');
$this->to_date = Carbon::now()->format('Y-m-d');
$this->orderBy = 'id';
}
public function read(){
$manage_projects = ManageProject::select('manage_projects.*', 'clients.client_name','tender_verieties.variety_name as project_type','settings_locations.location_name')
->join('clients', 'manage_projects.client_id', '=','clients.id')
->join('tender_verieties','manage_projects.project_variety_id','=','tender_verieties.id')
->join('settings_locations', 'manage_projects.location_id', '=','settings_locations.id')
->orderBy($this->orderBy, $this->orderAsc);
return $manage_projects->paginate($this->perPage ?? 10);
}
public function render()
{
$org = Organisation::latest()->first();
$datatable = $this->read();
return view('livewire.report.project-report-livewire',compact('datatable', 'org'));
}
}