Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrkidn committed Sep 20, 2023
1 parent 3712d7d commit 8cc48c8
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 15 deletions.
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,11 @@ This is the contents of the published config file:

```php
return [
'route-wildcard' => '*',
'default-status' => 302,
];
```

Optionally, you can publish the views using

```bash
php artisan vendor:publish --tag="filament-redirects-views"
```

## Usage

```php
```

## Documentation

For the full documentation, check [here](./docs/index.md).
Expand Down
1 change: 0 additions & 1 deletion config/filament-redirects.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [
'superadmin-only' => true,
'route-wildcard' => '*',
'default-status' => 302,
];
80 changes: 78 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,81 @@
# This package allows you to add redirects via Filament manually or with an import
# Redirects package for Filament and Laravel

## Introduction
This package allows you to add redirects via Filament manually or with an import via Excel or csv

## Installation

You can install the package via composer:

```bash
composer require codedor/filament-redirects
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="filament-redirects-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
php artisan vendor:publish --tag="filament-redirects-config"
```

This is the contents of the published config file:

```php
return [
'route-wildcard' => '*',
'default-status' => 302,
];
```

### Enabling the package

To make the redirects work, you have to register the Redirects middleware

```php
// app/Http/Kernel.php

protected $middleware = [
// ...
\Codedor\FilamentRedirects\Http\Middleware\Redirects::class,
];
```

And also register the plugin in your Panel provider:

```php
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\Codedor\FilamentRedirects\Filament\RedirectsPlugin::make(),
]);
}

```

## Configuration

This package has a couple of config values:

```php
<?php

return [
'route-wildcard' => '*',
'default-status' => 302,
];
```

### route-wildcard

This determines what the wildcard is in the CMS. By default this is `*`, but can be changed for whatever reason if necessary.

### default-status

The default HTTP status that the redirects uses, if none is given.

2 changes: 1 addition & 1 deletion src/Http/Middleware/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function handle(Request $request, Closure $next)
$activeRedirect = $urlMaps->first(function ($redirect) use ($current) {
$hasWildcard = Str::contains(
$redirect->clean_from,
config('url-mapping.route-wildcard', '*')
config('filament-redirects.route-wildcard', '*')
);

return
Expand Down

0 comments on commit 8cc48c8

Please sign in to comment.