Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Staff model #1793

Open
wants to merge 27 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7b44b07
Reorder properties and methods
adevade May 28, 2024
1fc37e3
Remove custom route model binding
adevade May 28, 2024
c79f4c0
Remove docblocks
adevade May 28, 2024
28740ed
Add missing cast
adevade May 28, 2024
5f54671
Update `full_name` accessor
adevade May 28, 2024
89cd30b
Update local search scope
adevade May 28, 2024
98e44b2
Update imports
adevade May 28, 2024
baef456
Use snake case accessor for consistency
adevade May 28, 2024
bfc90ec
Add class docblock for IDEs
adevade May 28, 2024
d93ef6d
Merge branch '1.x' into refactor-staff-model
adevade Jun 10, 2024
7357afa
Merge branch '1.x' into refactor-staff-model
adevade Jun 17, 2024
6cc5beb
Merge branch '1.x' into refactor-staff-model
adevade Jun 28, 2024
720c38f
Merge branch '1.x' into refactor-staff-model
adevade Jul 2, 2024
8d3753b
Merge branch '1.x' into refactor-staff-model
adevade Jul 11, 2024
bc9908e
Merge branch '1.x' into refactor-staff-model
adevade Aug 13, 2024
a997416
Merge branch '1.x' into refactor-staff-model
adevade Aug 22, 2024
19d91f6
Merge branch '1.x' into refactor-staff-model
adevade Sep 6, 2024
9ef2140
Merge branch '1.x' into refactor-staff-model
alecritson Sep 11, 2024
77fbc52
Tests
alecritson Sep 13, 2024
2dcdecc
Merge branch '1.x' into refactor-staff-model
adevade Sep 17, 2024
896a6e4
Merge branch '1.x' into refactor-staff-model
adevade Nov 25, 2024
9ff5ce4
chore: fix code style
actions-user Nov 25, 2024
da452eb
Update `firstname` `lastname` to have underscores
adevade Nov 25, 2024
1883f84
Merge branch 'refactor-staff-model' of https://github.com/adevade/lun…
adevade Nov 25, 2024
7899839
Fix migrations for SQLite
adevade Nov 25, 2024
af97cf2
Add fallbacks for old keys
adevade Nov 25, 2024
860be2c
Fix fallbacks to actually work...
adevade Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the docs at https://lunar-panel.vercel.app/
- [ ] Tax Zone types are "country", "states", "postcodes" -> would prefer it to be "countries" so it's consistent
- [ ] `ListField` FieldType shouldn't really have "Field" in its name -> change to simply "List"
- [ ] Sometimes we use "Enabled" other times "Active". Do we want to consider consistency here also?
- [ ] Staff "firstname" "lastname" I think should have underscores, e.g. "first_name"
- [x] Staff "firstname" "lastname" I think should have underscores, e.g. "first_name"
- [x] How to allow devs to extend Lunar's forms and tables
- [x] How to allow devs to overide validation rules
- [x] Allow devs to extend by adding their own pages/resources
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/database/factories/StaffFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class StaffFactory extends Factory
public function definition(): array
{
return [
'firstname' => $this->faker->firstName(),
'lastname' => $this->faker->lastName(),
'first_name' => $this->faker->firstName(),
'last_name' => $this->faker->lastName(),
'admin' => $this->faker->boolean(5),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

return new class extends Migration
{
public function up(): void
{
Schema::table($this->prefix.'staff', function (Blueprint $table) {
$table->renameColumn('firstname', 'first_name');
});
}

public function down(): void
{
Schema::table($this->prefix.'staff', function (Blueprint $table) {
$table->renameColumn('first_name', 'firstname');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

return new class extends Migration
{
public function up(): void
{
Schema::table($this->prefix.'staff', function (Blueprint $table) {
$table->renameColumn('lastname', 'last_name');
});
}

public function down(): void
{
Schema::table($this->prefix.'staff', function (Blueprint $table) {
$table->renameColumn('last_name', 'lastname');
});
}
};
8 changes: 4 additions & 4 deletions packages/admin/resources/lang/en/staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
'plural_label' => 'Staff',

'table' => [
'firstname' => [
'first_name' => [
'label' => 'First Name',
],
'lastname' => [
'last_name' => [
'label' => 'Last Name',
],
'email' => [
Expand All @@ -22,10 +22,10 @@
],

'form' => [
'firstname' => [
'first_name' => [
'label' => 'First Name',
],
'lastname' => [
'last_name' => [
'label' => 'Last Name',
],
'email' => [
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/resources/lang/es/staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
'plural_label' => 'Personal',

'table' => [
'firstname' => [
'first_name' => [
'label' => 'Nombre',
],
'lastname' => [
'last_name' => [
'label' => 'Apellido',
],
'email' => [
Expand All @@ -22,10 +22,10 @@
],

'form' => [
'firstname' => [
'first_name' => [
'label' => 'Nombre',
],
'lastname' => [
'last_name' => [
'label' => 'Apellido',
],
'email' => [
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/resources/lang/fr/staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
'plural_label' => 'Personnel',

'table' => [
'firstname' => [
'first_name' => [
'label' => 'Prénom',
],
'lastname' => [
'last_name' => [
'label' => 'Nom de famille',
],
'email' => [
Expand All @@ -22,10 +22,10 @@
],

'form' => [
'firstname' => [
'first_name' => [
'label' => 'Prénom',
],
'lastname' => [
'last_name' => [
'label' => 'Nom de famille',
],
'email' => [
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/resources/lang/nl/staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
'plural_label' => 'Personeel',

'table' => [
'firstname' => [
'first_name' => [
'label' => 'Voornaam',
],
'lastname' => [
'last_name' => [
'label' => 'Achternaam',
],
'email' => [
Expand All @@ -22,10 +22,10 @@
],

'form' => [
'firstname' => [
'first_name' => [
'label' => 'Voornaam',
],
'lastname' => [
'last_name' => [
'label' => 'Achternaam',
],
'email' => [
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/Console/Commands/MakeLunarAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class MakeLunarAdminCommand extends Command
protected function getUserData(): array
{
return [
'firstname' => $this->options['firstname'] ?? text(
'first_name' => $this->options['firstname'] ?? text(
label: 'First Name',
required: true,
),

'lastname' => $this->options['lastname'] ?? text(
'last_name' => $this->options['lastname'] ?? text(
label: 'Last Name',
required: true,
),
Expand Down
16 changes: 8 additions & 8 deletions packages/admin/src/Filament/Resources/StaffResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ protected static function getMainFormComponents(): array

protected static function getFirstNameFormComponent(): Component
{
return Forms\Components\TextInput::make('firstname')
->label(__('lunarpanel::staff.form.firstname.label'))
return Forms\Components\TextInput::make('first_name')
->label(__('lunarpanel::staff.form.first_name.label'))
->required()
->maxLength(255)
->autofocus();
}

protected static function getLastNameFormComponent(): Component
{
return Forms\Components\TextInput::make('lastname')
->label(__('lunarpanel::staff.form.lastname.label'))
return Forms\Components\TextInput::make('last_name')
->label(__('lunarpanel::staff.form.last_name.label'))
->required()
->maxLength(255)
->autofocus();
Expand Down Expand Up @@ -169,10 +169,10 @@ public static function getDefaultTable(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('firstname')
->label(__('lunarpanel::staff.table.firstname.label')),
Tables\Columns\TextColumn::make('lastname')
->label(__('lunarpanel::staff.table.lastname.label')),
Tables\Columns\TextColumn::make('first_name')
->label(__('lunarpanel::staff.table.first_name.label')),
Tables\Columns\TextColumn::make('last_name')
->label(__('lunarpanel::staff.table.last_name.label')),
Tables\Columns\TextColumn::make('email')
->label(__('lunarpanel::staff.table.email.label')),
Tables\Columns\TextColumn::make('admin')
Expand Down
Loading