This commit is contained in:
Martin Folkerts 2024-03-12 12:09:29 +01:00
parent 25715ddef6
commit 62b9942a53
7 changed files with 35 additions and 7 deletions

View file

@ -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')

View file

@ -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.');
}
},
],

View file

@ -1,6 +1,6 @@
<?php
namespace App\Livewire\Project;
namespace App\Livewire\Projects;
use App\Livewire\Forms\MailingForm;
use App\Models\ProjectReport;

View 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.'%');
}
}

View file

@ -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>

View file

@ -10,7 +10,7 @@ library(tidyverse)
library(lubridate)
library(exactextractr)
library(CIprep)
library(CIprep)
# Vang alle command line argumenten op
args <- commandArgs(trailingOnly = TRUE)