dev-think-one /
nova-resource-dynamic-export
| 1 | <?php |
||
| 2 | |||
| 3 | namespace NovaResourceDynamicExport; |
||
| 4 | |||
| 5 | use Closure; |
||
| 6 | |||
| 7 | class DynamicExport |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Indicates if NovaExportConfiguration migrations will be run. |
||
| 11 | */ |
||
| 12 | public static bool $runsMigrations = true; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Indicates if NovaExportConfiguration will provide download route. |
||
| 16 | */ |
||
| 17 | public static bool $useRoutes = true; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Route Configuration callback |
||
| 21 | */ |
||
| 22 | public static Closure|null $routeConfigurationCallback = null; |
||
| 23 | |||
| 24 | public static function ignoreMigrations(): static |
||
| 25 | { |
||
| 26 | static::$runsMigrations = false; |
||
| 27 | |||
| 28 | return new static; |
||
| 29 | } |
||
| 30 | |||
| 31 | public static function withoutRoutes(): static |
||
| 32 | { |
||
| 33 | static::$useRoutes = false; |
||
| 34 | |||
| 35 | return new static; |
||
| 36 | } |
||
| 37 | |||
| 38 | 10 | public static function routeConfiguration(?\Closure $callback = null): mixed |
|
| 39 | { |
||
| 40 | 10 | if($callback) { |
|
| 41 | static::$routeConfigurationCallback = $callback; |
||
| 42 | |||
| 43 | return new static; |
||
| 44 | } |
||
| 45 | |||
| 46 | 10 | if(is_callable(static::$routeConfigurationCallback)) { |
|
| 47 | return call_user_func(static::$routeConfigurationCallback); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 48 | } |
||
| 49 | |||
| 50 | 10 | return [ |
|
| 51 | 10 | 'prefix' => 'downloads/exports', |
|
| 52 | 10 | 'middleware' => config('nova.middleware'), |
|
| 53 | 10 | ]; |
|
| 54 | } |
||
| 55 | |||
| 56 | } |
||
| 57 |