Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Oct 30, 2024
1 parent 9034c1a commit d7844ff
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 22 deletions.
16 changes: 13 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"spatie/laravel-package-tools": "^1.15.0"
"spatie/laravel-package-tools": "^1.15.0",
"vormkracht10/laravel-redirects": "@dev"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"larastan/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.1",
"pestphp/pest-plugin-arch": "^2.0",
Expand Down Expand Up @@ -72,5 +73,14 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"repositories": {
"laravel-redirects": {
"type": "path",
"url": "/var/www/laravel-redirects",
"options": {
"symlink": true
}
}
}
}
19 changes: 0 additions & 19 deletions database/migrations/create_redirects_table.php.stub

This file was deleted.

23 changes: 23 additions & 0 deletions database/migrations/create_redirects_table_filament.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

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::create('redirects', function (Blueprint $table) {
$table->foreignUlid('site_ulid')->nullable()->constrained(table: 'sites', column: 'ulid')->cascadeOnUpdate()->cascadeOnDelete()->after('ulid');
$table->char('language_code', 2)->nullable()->after('site_ulid');
$table->char('country_code', 2)->nullable()->after('language_code');
$table->foreignUlid('content_ulid')->nullable()->constrained(table: 'content', column: 'ulid')->cascadeOnUpdate()->cascadeOnDelete()->after('path');

$table->foreign(['language_code', 'country_code'])->references(['code', 'country_code'])->on('languages')->cascadeOnUpdate()->nullOnDelete();
});
}
};
73 changes: 73 additions & 0 deletions src/Resources/RedirectResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Vormkracht10\FilamentRedirects\Resources;

use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Vormkracht10\Redirects\Models\Redirect;
use Vormkracht10\Backstage\Resources\RedirectResource\Pages;

class RedirectResource extends Resource
{
protected static ?string $model = Redirect::class;

protected static ?string $navigationIcon = 'heroicon-o-arrows-right-left';

public static ?string $recordTitleAttribute = 'name';

public static function getModelLabel(): string
{
return __('Redirect');
}

public static function getPluralModelLabel(): string
{
return __('Redirects');
}

public static function form(Form $form): Form
{
return $form
->schema([]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('path')
->searchable()
->sortable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListRedirects::route('/'),
'create' => Pages\CreateRedirect::route('/create'),
'edit' => Pages\EditRedirect::route('/{record}/edit'),
];
}
}
11 changes: 11 additions & 0 deletions src/Resources/RedirectResource/Pages/CreateRedirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Vormkracht10\FilamentRedirects\Resources\RedirectResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use Vormkracht10\Backstage\Resources\RedirectResource;

class CreateRedirect extends CreateRecord
{
protected static string $resource = RedirectResource::class;
}
19 changes: 19 additions & 0 deletions src/Resources/RedirectResource/Pages/EditRedirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Vormkracht10\FilamentRedirects\Resources\RedirectResource\Pages;

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Vormkracht10\Backstage\Resources\RedirectResource;

class EditRedirect extends EditRecord
{
protected static string $resource = RedirectResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
19 changes: 19 additions & 0 deletions src/Resources/RedirectResource/Pages/ListRedirects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Vormkracht10\FilamentRedirects\Resources\RedirectResource\Pages;

use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Vormkracht10\Backstage\Resources\RedirectResource;

class ListRedirects extends ListRecords
{
protected static string $resource = RedirectResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

0 comments on commit d7844ff

Please sign in to comment.