CasperSecurity
<?php
namespace App\Http\Livewire\Report;
use App\Models\Client;
use App\Models\Organisation;
use Carbon\Carbon;
use Livewire\Component;
use mysql_xdevapi\Collection;
class ClientReportLivewire extends Component
{
public $search;
public $perPage = 10;
public $orderBy = 'id';
public $orderAsc = 'asc';
public $from_date, $to_date, $data;
/* public $datatable = [];*/
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()
{
// $client = new Collection();
$client = Client::where('status', 1)->orderBy($this->orderBy, $this->orderAsc);
return $client->paginate($this->perPage ?? 10);
// dd($this->orderAsc);
// if(sizeof($client)>0){
//// dd($client);
// }
// if ($this->search !== null) {
// return $client->get();
// } else {
// $client->where('status', 1);
//
// if (in_array($this->orderBy, ['client_name', 'client_category_id', 'client_address'])) {
// $client->orderBy($this->orderBy, $this->orderAsc);
// }
// dd($client);
// return $client->paginate($this->perPage ?? 10);
// }
}
public function render()
{
// dd($this->orderAsc);
$org = Organisation::latest()->first();
$datatable = $this->read();
return view('livewire.report.client-report-livewire', compact('datatable', 'org'));
}
}