Skip to content

Commit

Permalink
Added ...TrimStringsAndConvertEmptyStringsToNull
Browse files Browse the repository at this point in the history
  • Loading branch information
kreaweb.be committed Jul 31, 2024
1 parent 7dab6a9 commit 1fa67e1
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 7 deletions.
39 changes: 33 additions & 6 deletions _ide_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* A helper file for Laravel, to provide autocomplete information to your IDE
* Generated for Laravel 11.18.1.
* Generated for Laravel 11.19.0.
*
* This file should not be included in your code, only analyzed by your IDE!
*
Expand Down Expand Up @@ -25176,7 +25176,7 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
/**
* Add a "where like" clause to the query.
*
* @param string $column
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
* @param string $value
* @param bool $caseSensitive
* @param string $boolean
Expand All @@ -25191,7 +25191,7 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
/**
* Add an "or where like" clause to the query.
*
* @param string $column
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
* @param string $value
* @param bool $caseSensitive
* @return \Illuminate\Database\Query\Builder
Expand All @@ -25204,7 +25204,7 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
/**
* Add a "where not like" clause to the query.
*
* @param string $column
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
* @param string $value
* @param bool $caseSensitive
* @param string $boolean
Expand All @@ -25218,7 +25218,7 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
/**
* Add an "or where not like" clause to the query.
*
* @param string $columns
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
* @param string $value
* @param bool $caseSensitive
* @return \Illuminate\Database\Query\Builder
Expand Down Expand Up @@ -25978,7 +25978,7 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
return $instance->orWhereAll($columns, $operator, $value);
}
/**
* Add an "where" clause to the query for multiple columns with "or" conditions between them.
* Add a "where" clause to the query for multiple columns with "or" conditions between them.
*
* @param string[] $columns
* @param string $operator
Expand All @@ -26003,6 +26003,33 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
{
/** @var \Illuminate\Database\Query\Builder $instance */
return $instance->orWhereAny($columns, $operator, $value);
}
/**
* Add a "where not" clause to the query for multiple columns where none of the conditions should be true.
*
* @param string[] $columns
* @param string $operator
* @param mixed $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder
* @static
*/ public static function whereNone($columns, $operator = null, $value = null, $boolean = 'and')
{
/** @var \Illuminate\Database\Query\Builder $instance */
return $instance->whereNone($columns, $operator, $value, $boolean);
}
/**
* Add an "or where not" clause to the query for multiple columns where none of the conditions should be true.
*
* @param string[] $columns
* @param string $operator
* @param mixed $value
* @return \Illuminate\Database\Query\Builder
* @static
*/ public static function orWhereNone($columns, $operator = null, $value = null)
{
/** @var \Illuminate\Database\Query\Builder $instance */
return $instance->orWhereNone($columns, $operator, $value);
}
/**
* Add a "group by" clause to the query.
Expand Down
4 changes: 3 additions & 1 deletion app/Livewire/Gedcom/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

namespace App\Livewire\Gedcom;

use Illuminate\View\View;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
// use Laravel\Jetstream\Events\AddingTeam;
use Illuminate\View\View;
use Livewire\Component;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Livewire\WithFileUploads;
Expand All @@ -14,6 +15,7 @@
class Import extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;
use WithFileUploads;

// -----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Add/Child.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Add;

use App\Livewire\Forms\People\ChildForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use App\PersonPhotos;
use Illuminate\Http\UploadedFile;
Expand All @@ -18,6 +19,7 @@
class Child extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;
use WithFileUploads;

// -----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Add/Father.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Add;

use App\Livewire\Forms\People\FatherForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use App\PersonPhotos;
use Illuminate\Http\UploadedFile;
Expand All @@ -18,6 +19,7 @@
class Father extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;
use WithFileUploads;

// -----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Add/Mother.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Add;

use App\Livewire\Forms\People\MotherForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use App\PersonPhotos;
use Illuminate\Http\UploadedFile;
Expand All @@ -18,6 +19,7 @@
class Mother extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;
use WithFileUploads;

// -----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Add/Partner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Add;

use App\Livewire\Forms\People\PartnerForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Couple;
use App\Models\Person;
use App\PersonPhotos;
Expand All @@ -19,6 +20,7 @@
class Partner extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;
use WithFileUploads;

// -----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Add/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Add;

use App\Livewire\Forms\People\PersonForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\PersonPhotos;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
Expand All @@ -16,6 +17,7 @@
class Person extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;
use WithFileUploads;

// -----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Edit/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Edit;

use App\Livewire\Forms\People\ContactForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use Illuminate\View\View;
use Livewire\Component;
Expand All @@ -13,6 +14,7 @@
class Contact extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;

// -----------------------------------------------------------------------
public Person $person;
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Edit/Death.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Edit;

use App\Livewire\Forms\People\DeathForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use Carbon\Carbon;
use Illuminate\View\View;
Expand All @@ -14,6 +15,7 @@
class Death extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;

// -----------------------------------------------------------------------
public Person $person;
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Edit/Family.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Edit;

use App\Livewire\Forms\People\FamilyForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Couple;
use App\Models\Person;
use Illuminate\Support\Collection;
Expand All @@ -15,6 +16,7 @@
class Family extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;

// -----------------------------------------------------------------------
public $person;
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Edit/Partner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Edit;

use App\Livewire\Forms\People\PartnerForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use Illuminate\Support\Collection;
use Illuminate\View\View;
Expand All @@ -14,6 +15,7 @@
class Partner extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;

// -----------------------------------------------------------------------
public $person;
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/People/Edit/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Livewire\People\Edit;

use App\Livewire\Forms\People\ProfileForm;
use App\Livewire\Traits\TrimStringsAndConvertEmptyStringsToNull;
use App\Models\Person;
use Carbon\Carbon;
use Illuminate\View\View;
Expand All @@ -14,6 +15,7 @@
class Profile extends Component
{
use Interactions;
use TrimStringsAndConvertEmptyStringsToNull;

// -----------------------------------------------------------------------
public Person $person;
Expand Down
20 changes: 20 additions & 0 deletions app/Livewire/Traits/TrimStringsAndConvertEmptyStringsToNull.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace App\Livewire\Traits;

trait TrimStringsAndConvertEmptyStringsToNull
{
// -----------------------------------------------------------------------
// ONLY needed in Livewire forms, NOT in blade forms
// -----------------------------------------------------------------------
public function updatedTrimStringsAndConvertEmptyStringsToNull($name, $value)
{
if (is_string($value)) {
$trimmed = trim($value);

data_set($this, $name, $trimmed === '' ? null : $trimmed);
}
}
}

0 comments on commit 1fa67e1

Please sign in to comment.