-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from code4romania/392-update-dob-and-age-fiel…
…ds-for-children-table Children fields
- Loading branch information
Showing
4 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Forms\Components; | ||
|
||
use Carbon\Carbon; | ||
use Closure; | ||
use Filament\Forms\Components\TextInput; | ||
|
||
class DateInput extends TextInput | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->placeholder('dd-mm-yyyy'); | ||
$this->mask('99-99-9999'); | ||
$this->formatStateUsing(fn (string $state) => $state ? Carbon::parse($state)->format('d-m-Y') : null); | ||
$this->rules([ | ||
'date_format:d-m-Y', | ||
fn (): Closure => function (string $attribute, $value, Closure $fail) { | ||
if (Carbon::createFromFormat('d-m-Y', $value)->greaterThan(now())) { | ||
$fail(__('validation.before_or_equal', [ | ||
'date' => now()->format('d-m-Y'), | ||
])); | ||
} | ||
}, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
database/migrations/2024_12_11_113011_drop_age_column_from_childrens_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('childrens', function (Blueprint $table) { | ||
$table->dropColumn('age'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('childrens', function (Blueprint $table) { | ||
// | ||
}); | ||
} | ||
}; |