Skip to content

Commit da452eb

Browse files
committed
Update firstname lastname to have underscores
1 parent 896a6e4 commit da452eb

13 files changed

Lines changed: 75 additions & 52 deletions

File tree

‎packages/admin/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the docs at https://lunar-panel.vercel.app/
1313
- [ ] Tax Zone types are "country", "states", "postcodes" -> would prefer it to be "countries" so it's consistent
1414
- [ ] `ListField` FieldType shouldn't really have "Field" in its name -> change to simply "List"
1515
- [ ] Sometimes we use "Enabled" other times "Active". Do we want to consider consistency here also?
16-
- [ ] Staff "firstname" "lastname" I think should have underscores, e.g. "first_name"
16+
- [x] Staff "firstname" "lastname" I think should have underscores, e.g. "first_name"
1717
- [x] How to allow devs to extend Lunar's forms and tables
1818
- [x] How to allow devs to overide validation rules
1919
- [x] Allow devs to extend by adding their own pages/resources

‎packages/admin/database/factories/StaffFactory.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class StaffFactory extends Factory
2020
public function definition(): array
2121
{
2222
return [
23-
'firstname' => $this->faker->firstName(),
24-
'lastname' => $this->faker->lastName(),
23+
'first_name' => $this->faker->firstName(),
24+
'last_name' => $this->faker->lastName(),
2525
'admin' => $this->faker->boolean(5),
2626
'email' => $this->faker->unique()->safeEmail(),
2727
'email_verified_at' => now(),
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Support\Facades\Schema;
5+
use Lunar\Base\Migration;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table($this->prefix.'staff', function (Blueprint $table) {
12+
$table->renameColumn('firstname', 'first_name');
13+
$table->renameColumn('lastname', 'last_name');
14+
});
15+
}
16+
17+
public function down(): void
18+
{
19+
Schema::table($this->prefix.'staff', function (Blueprint $table) {
20+
$table->renameColumn('first_name', 'firstname');
21+
$table->renameColumn('last_name', 'lastname');
22+
});
23+
}
24+
};

‎packages/admin/resources/lang/en/staff.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
'plural_label' => 'Staff',
88

99
'table' => [
10-
'firstname' => [
10+
'first_name' => [
1111
'label' => 'First Name',
1212
],
13-
'lastname' => [
13+
'last_name' => [
1414
'label' => 'Last Name',
1515
],
1616
'email' => [
@@ -22,10 +22,10 @@
2222
],
2323

2424
'form' => [
25-
'firstname' => [
25+
'first_name' => [
2626
'label' => 'First Name',
2727
],
28-
'lastname' => [
28+
'last_name' => [
2929
'label' => 'Last Name',
3030
],
3131
'email' => [

‎packages/admin/resources/lang/es/staff.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
'plural_label' => 'Personal',
88

99
'table' => [
10-
'firstname' => [
10+
'first_name' => [
1111
'label' => 'Nombre',
1212
],
13-
'lastname' => [
13+
'last_name' => [
1414
'label' => 'Apellido',
1515
],
1616
'email' => [
@@ -22,10 +22,10 @@
2222
],
2323

2424
'form' => [
25-
'firstname' => [
25+
'first_name' => [
2626
'label' => 'Nombre',
2727
],
28-
'lastname' => [
28+
'last_name' => [
2929
'label' => 'Apellido',
3030
],
3131
'email' => [

‎packages/admin/resources/lang/fr/staff.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
'plural_label' => 'Personnel',
88

99
'table' => [
10-
'firstname' => [
10+
'first_name' => [
1111
'label' => 'Prénom',
1212
],
13-
'lastname' => [
13+
'last_name' => [
1414
'label' => 'Nom de famille',
1515
],
1616
'email' => [
@@ -22,10 +22,10 @@
2222
],
2323

2424
'form' => [
25-
'firstname' => [
25+
'first_name' => [
2626
'label' => 'Prénom',
2727
],
28-
'lastname' => [
28+
'last_name' => [
2929
'label' => 'Nom de famille',
3030
],
3131
'email' => [

‎packages/admin/resources/lang/nl/staff.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
'plural_label' => 'Personeel',
88

99
'table' => [
10-
'firstname' => [
10+
'first_name' => [
1111
'label' => 'Voornaam',
1212
],
13-
'lastname' => [
13+
'last_name' => [
1414
'label' => 'Achternaam',
1515
],
1616
'email' => [
@@ -22,10 +22,10 @@
2222
],
2323

2424
'form' => [
25-
'firstname' => [
25+
'first_name' => [
2626
'label' => 'Voornaam',
2727
],
28-
'lastname' => [
28+
'last_name' => [
2929
'label' => 'Achternaam',
3030
],
3131
'email' => [

‎packages/admin/src/Console/Commands/MakeLunarAdminCommand.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ class MakeLunarAdminCommand extends Command
3232
protected function getUserData(): array
3333
{
3434
return [
35-
'firstname' => $this->options['firstname'] ?? text(
35+
'first_name' => $this->options['firstname'] ?? text(
3636
label: 'First Name',
3737
required: true,
3838
),
3939

40-
'lastname' => $this->options['lastname'] ?? text(
40+
'last_name' => $this->options['lastname'] ?? text(
4141
label: 'Last Name',
4242
required: true,
4343
),

‎packages/admin/src/Filament/Resources/StaffResource.php‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ protected static function getMainFormComponents(): array
6363

6464
protected static function getFirstNameFormComponent(): Component
6565
{
66-
return Forms\Components\TextInput::make('firstname')
67-
->label(__('lunarpanel::staff.form.firstname.label'))
66+
return Forms\Components\TextInput::make('first_name')
67+
->label(__('lunarpanel::staff.form.first_name.label'))
6868
->required()
6969
->maxLength(255)
7070
->autofocus();
7171
}
7272

7373
protected static function getLastNameFormComponent(): Component
7474
{
75-
return Forms\Components\TextInput::make('lastname')
76-
->label(__('lunarpanel::staff.form.lastname.label'))
75+
return Forms\Components\TextInput::make('last_name')
76+
->label(__('lunarpanel::staff.form.last_name.label'))
7777
->required()
7878
->maxLength(255)
7979
->autofocus();
@@ -169,10 +169,10 @@ public static function getDefaultTable(Table $table): Table
169169
{
170170
return $table
171171
->columns([
172-
Tables\Columns\TextColumn::make('firstname')
173-
->label(__('lunarpanel::staff.table.firstname.label')),
174-
Tables\Columns\TextColumn::make('lastname')
175-
->label(__('lunarpanel::staff.table.lastname.label')),
172+
Tables\Columns\TextColumn::make('first_name')
173+
->label(__('lunarpanel::staff.table.first_name.label')),
174+
Tables\Columns\TextColumn::make('last_name')
175+
->label(__('lunarpanel::staff.table.last_name.label')),
176176
Tables\Columns\TextColumn::make('email')
177177
->label(__('lunarpanel::staff.table.email.label')),
178178
Tables\Columns\TextColumn::make('admin')

‎packages/admin/src/Models/Staff.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
/**
1818
* @property int $id
1919
* @property bool $admin
20-
* @property string $firstname
21-
* @property string $lastname
20+
* @property string $first_name
21+
* @property string $last_name
2222
* @property string $full_name
2323
* @property string $email
2424
* @property string $password
@@ -40,8 +40,8 @@ class Staff extends Authenticatable implements FilamentUser, HasName
4040
protected $guard_name = 'staff';
4141

4242
protected $fillable = [
43-
'firstname',
44-
'lastname',
43+
'first_name',
44+
'last_name',
4545
'admin',
4646
'email',
4747
'password',
@@ -65,7 +65,7 @@ class Staff extends Authenticatable implements FilamentUser, HasName
6565
protected function fullName(): Attribute
6666
{
6767
return Attribute::get(
68-
fn (): string => "{$this->firstname} {$this->lastname}",
68+
fn (): string => "{$this->first_name} {$this->last_name}",
6969
);
7070
}
7171

@@ -92,7 +92,7 @@ public function scopeSearch(Builder $query, ?string $terms): void
9292
}
9393

9494
foreach (explode(' ', $terms) as $term) {
95-
$query->whereAny(['email', 'firstname', 'lastname'], 'LIKE', "%{$term}%");
95+
$query->whereAny(['email', 'first_name', 'last_name'], 'LIKE', "%{$term}%");
9696
}
9797
}
9898

0 commit comments

Comments
 (0)