mykemeynell / infinity
Infinity CMS package
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Language:CSS
Type:package
Requires
- doctrine/dbal: ^3.3
- laravel/ui: ^3.4
- mykemeynell/laraveluuid: ^1.0
This package is auto-updated.
Last update: 2024-11-09 18:27:31 UTC
README
Installation
Prerequisites
- Already have your database configured in your
.env
file. - You have already set your
APP_KEY
(you will be asked if you would like to do this as part of the installation if you haven't already set one).
Installation with Composer
-
composer require mykemeynell/infinity
-
Include the Infinity service provider in your
config/app.php
config
'providers' => [ // ... \Infinity\InfinityServiceProvider::class, // ... ]
-
In
config/auth.php
change theproviders > user > model
key to\Infinity\Models\Users\User::class
. -
Run
php artisan infinity:install
to install Infinity.
Configuration
Load Infinity Routes Differently
Infinity's routes are loaded by default without further configuration as part of
the Infinity Service Provider. However, if you would like to change the point at
which the routes are loaded in, you can do so by adding
\Infinity\Facades\Infinity::routes();
to your routes file. This will also
prevent the service provider from loading them automatically.
This is useful if, for example; you have a generic Route::get('{slug}', ...)
route defined - and you need to load Infinity routes beforehand, so they're not
captured by this 'catchall'
Environment Variables
You can read more about environment configuration options here.
Creating Resources
php artisan infinity:make:resource <name>
A new resource class will be created under app/Infinity/<name>.php
- here
you can modify how the resource is displayed and how particular aspects are
handled within Infinity.
Cards
Cards are small snippet views of data that are rendered on the dashboard. To create a new card run:
php artisan infinity:make:card <name>
You will need to tell the card which view to render by specifying the view name
in the view(): string
method. This view will be rendered in the cards
content area, so there is no need to create the card title.
To change the title displayed in the card header area, specify the following property with a value.
public static string $title = 'My Card';
If you only want your card to be shown to specific groups, you can use the
group
property.
public static array $groups = ['admin'];
Resource Options
Basic Resource Configuration
public static string $model;
Set the model that relates to the resource using the fully qualified namespace.
public static bool $displayInNavigation = true;
Whether the resource object should be displayed in the sidebar (Default: true
).
public static string $icon;
Configure the icon of the resource, this can be a single FontAwesome icon, or
a FREE/PRO alternative if a PRO licence is configured. (Default: 'fas fa-infinity / fad fa-infinity'
)
public static ?string $controller;
The fully qualified namespace of the resource's controller.
If this is set, then it will be returned without further tests.
Otherwise, a class with the name <Resource>Controller
will be tested in
the App\Http\Controllers
namespace. If such a class exists, then that
class will be used for this resource, otherwise a fallback of
\Infinity\Http\Controllers\InfinityBaseController::class
will be used.
Fields
To set the fields that are used for a resource you can modify the
Resource::fields()
method to return an array of the fields that you would
like outputted. The fields are output in the order they are specified.
Field Types
For available field methods, see Field Methods.
Field Methods
View Data
Attributes
If you wish to pass custom attributes through to a rendered view - you should
do so using the attributes
key.
[ 'attributes' => [ 'class' => 'text-blue-300 text-xs' ] ]
Conditional View Data
Specify conditional view attributes using the conditional
array key. Any
conditions that are evaluated to true
will be merged with the attribute
with the same key from attributes
in Attributes.
[ 'conditional' => [ 'class' => [ 'column_name:column_value' => 'applied_classes', 'column_name:another_value' => 'alternative_classes', ] ] ]
Resource Configuration Methods
fields(): array
Fields that are shown on the resource.index
route - these are used as
table columns.
For information on possible field types, see Field Types.
public function fields(): array { return [ ID::make()->hidden(), Text::make('name'), Text::make('email'), ]; }
formFields(): array
The configuration of this method is the same as fields(): array
, but these
fields are displayed when viewing resource routes that output forms.
If nothing is specified here, or the method is omitted then fields()
is
used instead.
public function formFields(): array { return array_merge_recursive($this->fields(), [ Password::make('password'), ]); }
excludedActions(): array
Methods that should be excluded from a resource - for example if you want to
remove the ability to view a single instance of a resource, you can specify the
ViewAction::class
action. This will also prevent the resource.show
resource route from being registered too.
public function excludedActions(): array { return [\Infinity\Actions\ViewAction::class]; }
additionalRoutes(): array
If you wish to add additional routes to a resource, then you can do so using the
additionalRoutes
method. This should return an array with values of
\Infinity\Resources\Routes\AdditionalRoute::class
.
public function additionalRoutes(): array { return [ AdditionalRoute::make('me')->setAction('showProfile') ]; }
Additional Route Methods
additionalGates(): array
Gates that can be added at a resource level. These can then be registered when
Infinity is in development mode by using the
infinity:debug:flush-permissions
artisan command.
public function additionalGates(): array { return ['viewProfile']; }
Artisan Commands
Using FontAwesome PRO
If you'd like to use FontAwesome PRO, you can use the following keys in your
.env
file - by default FontAwesome FREE is used.
If no Integrity is set then an exception is thrown.
FONTAWESOME_LICENCE= FONTAWESOME_SRC= FONTAWESOME_INTEGRITY=
You can read more about environment configuration options here.
Environment
Infinity Debug/Development
To enable debug/development artisan commands in Infinity, add the following to
your .env
file.
INFINITY_DEV=true