2020-04-23 00:49:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
|
|
|
|
use App\Models\Quote;
|
2020-05-04 23:22:31 +02:00
|
|
|
use App\Utils\Traits\WithSorting;
|
2020-09-03 11:14:24 +02:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2020-04-23 00:49:23 +02:00
|
|
|
use Livewire\Component;
|
|
|
|
use Livewire\WithPagination;
|
|
|
|
|
|
|
|
class QuotesTable extends Component
|
|
|
|
{
|
|
|
|
use WithSorting;
|
|
|
|
use WithPagination;
|
|
|
|
|
|
|
|
public $per_page = 10;
|
|
|
|
public $status = [];
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
$query = Quote::query()
|
2020-05-14 03:05:18 +02:00
|
|
|
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');
|
|
|
|
|
2020-09-03 11:14:24 +02:00
|
|
|
if (count($this->status) > 0) {
|
|
|
|
$query = $query->whereIn('status_id', $this->status);
|
2020-04-23 00:49:23 +02:00
|
|
|
}
|
|
|
|
|
2020-05-14 03:05:18 +02:00
|
|
|
$query = $query
|
2020-06-10 15:35:39 +02:00
|
|
|
->where('client_id', auth('contact')->user()->client->id)
|
2020-05-14 03:05:18 +02:00
|
|
|
->paginate($this->per_page);
|
2020-04-23 00:49:23 +02:00
|
|
|
|
|
|
|
return render('components.livewire.quotes-table', [
|
2020-09-06 11:38:10 +02:00
|
|
|
'quotes' => $query,
|
2020-04-23 00:49:23 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|