style updates
This commit is contained in:
@@ -4,14 +4,25 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void { Schema::create('team_members', function (Blueprint $table): void { $table->id();
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('team_members', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('job_title')->nullable();
|
||||
$table->text('biography')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->boolean('enabled')->default(true);
|
||||
$table->timestamps(); $table->softDeletes(); }); }
|
||||
public function down(): void { Schema::dropIfExists('team_members'); }
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('team_members');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,20 +10,53 @@ use Modules\Team\Models\TeamMember;
|
||||
|
||||
final class TeamMemberController extends Controller
|
||||
{
|
||||
public function index(): View { return view('team::admin.index', ['records' => TeamMember::query()->latest()->paginate(20)]); }
|
||||
public function create(): View { return view('team::admin.form'); }
|
||||
public function store(Request $request): RedirectResponse { $data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
public function index(): View
|
||||
{
|
||||
return view('team::admin.index', ['records' => TeamMember::query()->latest()->paginate(20)]);
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
return view('team::admin.form');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'job_title' => ['nullable', 'string'],
|
||||
'biography' => ['nullable', 'string'],
|
||||
'email' => ['nullable', 'string'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0'],
|
||||
'enabled' => ['sometimes', 'boolean']]); $data['enabled'] = $request->boolean('enabled'); TeamMember::create($data); return redirect()->route('team.index')->with('status', 'TeamMember created.'); }
|
||||
public function edit(TeamMember $teamMember): View { return view('team::admin.form', ['record' => $teamMember]); }
|
||||
public function update(Request $request, TeamMember $teamMember): RedirectResponse { $data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
TeamMember::create($data);
|
||||
|
||||
return redirect()->route('team.index')->with('status', 'TeamMember created.');
|
||||
}
|
||||
|
||||
public function edit(TeamMember $teamMember): View
|
||||
{
|
||||
return view('team::admin.form', ['record' => $teamMember]);
|
||||
}
|
||||
|
||||
public function update(Request $request, TeamMember $teamMember): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'job_title' => ['nullable', 'string'],
|
||||
'biography' => ['nullable', 'string'],
|
||||
'email' => ['nullable', 'string'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0'],
|
||||
'enabled' => ['sometimes', 'boolean']]); $data['enabled'] = $request->boolean('enabled'); $teamMember->update($data); return redirect()->route('team.index')->with('status', 'TeamMember updated.'); }
|
||||
public function destroy(TeamMember $teamMember): RedirectResponse { $teamMember->delete(); return back()->with('status', 'TeamMember deleted.'); }
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
$teamMember->update($data);
|
||||
|
||||
return redirect()->route('team.index')->with('status', 'TeamMember updated.');
|
||||
}
|
||||
|
||||
public function destroy(TeamMember $teamMember): RedirectResponse
|
||||
{
|
||||
$teamMember->delete();
|
||||
|
||||
return back()->with('status', 'TeamMember deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,16 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
final class TeamMember extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = 'team_members';
|
||||
protected $fillable = ['name', 'job_title', 'biography', 'email', 'sort_order', 'enabled'];
|
||||
|
||||
protected function casts(): array { return [
|
||||
'sort_order' => 'integer',
|
||||
'enabled' => 'boolean'
|
||||
]; }
|
||||
|
||||
protected $table = 'team_members';
|
||||
|
||||
protected $fillable = ['name', 'job_title', 'biography', 'email', 'sort_order', 'enabled'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'sort_order' => 'integer',
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,15 @@
|
||||
|
||||
namespace Modules\Team\Support;
|
||||
|
||||
final class ModuleInfo { public static function name(): string { return 'Team'; } public static function nameLower(): string { return 'team'; } }
|
||||
final class ModuleInfo
|
||||
{
|
||||
public static function name(): string
|
||||
{
|
||||
return 'Team';
|
||||
}
|
||||
|
||||
public static function nameLower(): string
|
||||
{
|
||||
return 'team';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
it('registers the Team administration route', function (): void { expect(Route::has('administration.team.index'))->toBeTrue(); });
|
||||
it('registers the Team administration route', function (): void {
|
||||
expect(Route::has('administration.team.index'))->toBeTrue();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user