wip
This commit is contained in:
parent
25715ddef6
commit
62b9942a53
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Livewire\Projects;
|
||||
|
||||
use App\Livewire\Searchable;
|
||||
use App\Models\Project;
|
||||
use App\Rules\DownloadDateRangeRule;
|
||||
use Carbon\Carbon;
|
||||
|
|
@ -12,7 +13,8 @@
|
|||
|
||||
class DownloadManager extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
use WithPagination, Searchable;
|
||||
|
||||
|
||||
public $project;
|
||||
|
||||
|
|
@ -62,7 +64,9 @@ public function saveDownloads()
|
|||
|
||||
public function render()
|
||||
{
|
||||
$downloads = $this->project->downloads()->orderBy('name', 'desc')->paginate(10, pageName: 'downloadPage');
|
||||
$query = $this->project->downloads()->orderBy('name', 'desc');
|
||||
$query = $this->applySearch($query);
|
||||
$downloads = $query->paginate(10, pageName: 'downloadPage');
|
||||
|
||||
return view('livewire.projects.download-manager',
|
||||
compact('downloads')
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ function ($attribute, $value, $fail) {
|
|||
if ($value && !is_file($value->getRealPath())) {
|
||||
$fail($attribute.' is geen geldig bestand.');
|
||||
} elseif ($value && !in_array(mime_content_type($value->getRealPath()), ['application/json'])) {
|
||||
$fail($attribute.' moet een JSON-bestand zijn.');
|
||||
// $fail($attribute.' moet een JSON-bestand zijn.');
|
||||
}
|
||||
},
|
||||
],
|
||||
|
|
@ -225,7 +225,7 @@ function ($attribute, $value, $fail) {
|
|||
if ($value && !is_file($value->getRealPath())) {
|
||||
$fail($attribute.' is geen geldig bestand.');
|
||||
} elseif ($value && !in_array(mime_content_type($value->getRealPath()), ['application/json'])) {
|
||||
$fail($attribute.' moet een JSON-bestand zijn.');
|
||||
// $fail($attribute.' moet een JSON-bestand zijn.');
|
||||
}
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Project;
|
||||
namespace App\Livewire\Projects;
|
||||
|
||||
use App\Livewire\Forms\MailingForm;
|
||||
use App\Models\ProjectReport;
|
||||
24
laravel_app/app/Livewire/Searchable.php
Normal file
24
laravel_app/app/Livewire/Searchable.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
trait Searchable
|
||||
{
|
||||
public $search = '';
|
||||
|
||||
public function updatedSearchable($property)
|
||||
{
|
||||
if ($property === 'search') {
|
||||
$this->resetPage();
|
||||
}
|
||||
}
|
||||
|
||||
protected function applySearch($query)
|
||||
{
|
||||
return $this->search === ''
|
||||
? $query
|
||||
: $query
|
||||
->where('email', 'like', '%'.$this->search.'%')
|
||||
->orWhere('number', 'like', '%'.$this->search.'%');
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg
|
|||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
@foreach($reports as $report)
|
||||
<livewire:project.report-row :$report :key="$report->id"/>
|
||||
<livewire:projects.report-row :$report :key="$report->id"/>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Reference in a new issue