Download the PHP package weblabormx/laravel-front without Composer
On this page you can find all versions of the php package weblabormx/laravel-front. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download weblabormx/laravel-front
More information about weblabormx/laravel-front
Files in weblabormx/laravel-front
Package laravel-front
Short Description Front is a administration panel for Laravel. It allows you to create CRUD easily in minutes. It allows to fully customize any part of the code.
License MIT
Informations about the package laravel-front
Front
This package was inspired on Laravel Nova.
Front is a administration panel for Laravel. It allows you to create CRUD easily in minutes. It allows to fully customize any part of the code.
Differences with Laravel Nova:
- Front is created just with PHP, so there isn't any dependency with any javascript framework.
- It tries to be simpler to modify and adapt to any use.
- Menu is not generated automatically
Documentation
Installation
The easiest way to install Laravel Front is using the base-laravel-front project as a base. But in case you want to install manually you can follow the next instructions.
- Install via composer executing
composer require weblabormx/laravel-front
- Execute
php artisan front:install
to install all necessary files (Will install configuration file and views)
Adapt the layout
- Add on your layout the code
@yield('after-nav')
as there is where Laravel Front shows the menu - Add on your layout the code
@yield('content')
as there is where Laravel Front shows the content of the cruds - Add on your layout the code
@yield('sidebar')
as there is where Laravel Front shows the filters on the menu - Add on your layout the code
@stack('scripts-footer')
as there is where Laravel Front shows the javascript info - Add on the layout the next code
@include('flash::message')
, this will show the success and errors messages - This package requires of jquery, so please be sure that its called before executing
@yield('scripts-footer')
- You can edit anything on the views published on
views/vendor/front
to adapt to your previous desing. - Edit the config.front to select the correct layout
Layout example
Basics
Laravel Front makes a use of different items that can be defined on the next way:
- Front Resources: Basically is the front end information about a model and that is wanted to have a CRUD. The resources saves information about which fields show on the cruds.
- Actions: Are actions that can be added to a resource, for example can be a resource for Reservations and there can be an action for "Mark as Paid"
- Filters: Filters works for filtering the data on the index page of a crud, for example for Reservations page you can filter the results to only show payed reservations
- Fields: The resources can have fields to show information
- Inputs: Are all the fields that add information as Text, Number, Select
- Texts: Are fields that only shows information as Alert, Title
- Components: Are more sophisticated fields that help on something like Panels, Line, FrontIndex
- Workers:_ Are helpers that executes something, this always return a value.
- Massives: Define how a massive edition should work. For example you can have the users CRUD, each user have a lot of reservations, and you want to edit massively all reservations for this user, you can add more information on this classes, for example, adding a new button that says "Remove all" or "Send request"
- Pages: Are information pages that only shows information, for example the Dashboard page
- Cards: Are information cards that can be shown on pages, for example: The total money earned today, The total debt, etc
- Lenses: Diferent views for an index page for a CRUD, for example Products can have different views or reports, one in general, other showing and ordered by most selled, etc.
Resources
A resource is a class that allows you to configure all the information about the front end of a Laravel Model. Things as fields, url, buttons and more are configured on this file.
Registering resources
The front resources are saved by default on App\Front
folder. You can generate a new front using the artisan command (In this case a new resource alled Page):
A new file on App\Front\
will be added, you need to configure there the fields, base url and model direction.
And then you will need to add the route. This will generate a access on /pages
(It uses the plural name)
The front resources needs to have a Policy name, so please create a Policy for the model and be sure that are defined on the AuthServiceProvider
(Just if you are using different folder for models as Laravel detects it automatically)
Working with resources
There are some basic variables that can be added on the resource
Funtions
index
If you need to run some algorithm just when you visit the resource you can use Index()
.
indexQuery
Modifying query of results
If you want to modify the results of CRUD you are able to modify it with indexQuery
function
create
If you need to insert a data that is not found between the fields of your resource, you can use the create function.
Index_links
you can create a button with the function Index_links
which will appear in the main view of the resource.
links
It works in the same way as index_links, the difference is that the button will appear when visiting some data from our resource.
Pagination
By default a pagination is created with 50 elements, if you want to modify the quantity you can add a new attribute called pagination
on the resource
Actions to be executed after a crud action is done
You can add to any resource some actions to be done after something is done adding the next functions on the Front File
index()
show($object)
store($object, $request)
update($object, $request)
destroy($object)
Fields
Each resource contains a fields
method, where it returns an array with the list of all the fields that the resource should have.
Field column convention
As noted above, Front will "snake case" the displayable name of the field to determine the underlying database column. However, if necessary, you may pass the column name as the second argument to the field's make method:
Attributes of the fields
Showing / Hidding Fields
- hideFromIndex
- hideFromDetail
- hideWhenCreating
- hideWhenUpdating
- onlyOnIndex
- onlyOnDetail
- onlyOnForms
- onlyOnEdit
- onlyOnCreate
- exceptOnForms
Others
- rules
- creationRules
- setValue
- setDirectory
- default
- setWidth
- filterQuery
- options
You may chain any of these methods onto your field's definition in order to instruct Frpmt where the field should be displayed:
Dont show input if there are values set
Sometimes we would want to hide an input if we set the value on the request side or if we are using the create button on a relationship, for that we can use of function called hideWhenValuesSet
, this is compatible with all inputs.
Conditional values
If we want to show an input based on the value of another input we can do it using the conditional($condition)
function or conditionalOld($column, $value)
functions. To this to work is required to have conditionize2 (Already loaded with the EasyJsLibrary)
The only differences between conditional and conditionalOld are the versions of conditionize2 library.
Field Panels
If your resource contains many fields, your resource "detail" screen can become crowded. For that reason, you may choose to break up groups of fields into their own "panels":
You may do this by creating a new Panel instance within the fields method of a resource. Each panel requires a name and an array of fields that belong to that panel:
Field types
All the fields available on front:
- Autocomplete
- BelongsTo
- BelongsToMany
- Boolean
- Check
- Checkboxes
- Code
- Date
- DateTime
- Disabled
- File
- HasMany
- Hidden
- ID
- Image
- Input
- Money
- MorphMany
- MorphTo
- MorphToMany
- Number
- Password
- Select
- Text
- Textarea
- Time
- Trix
Text types
- Alert
- Heading
- HorizontalDescription
- Paragraph
- Table
- Title
Components
- FrontCreate
- FrontIndex
- Line
- Panel
- ShowCards
- Welcome
Laravel Front is growing so it is normal that we are adding new types of fields and it is not documented yet, if you want to see all the types of fields that your Laravel Front project has go to vendor\weblabormx\laravel-front\src\inputs
BelongsTo
if you want to insert some data from another table you can do it with BelongsTo referencing the model that has the data you need.
Create the relationship in the model
HasMany
If your resource has a relation of many you can use the HasMany, indicating the model it relates to:
Create the relationship in the model in plural.
MorphTo
The morphTo
field corresponds to a morphTo
of the eloquent relation, for example if a price
model has a polymorphic relation with the courses
and products
models, the relation can be added to the price
resource in this way.
in the course and products model
Remember to follow the eloquent able
structure for polymorphic relationships.
Massive editions
If you want to a relationship resource to be edited massively just add enableMassive()
function.
Images
If you need to use the Image
field you will have to change FILESYSTEM_DRIVER = local
to FILESYSTEM_DRIVER = public
in the .env
file.
Sometimes you also need to change to public on the route config\filesystems.php
.
Filters
You can add filters to a resource to filter the data, the filters are stored on App\Front\Filters
folder. You can add filters by executing the command php artisan front:filter FilterName
Once you execute the command by first time the folder will be generated and the filter SearchFilter
will be added automatically.
Once is created you need to add it on the resource page
Adding a default value
You can add a default value to the filter by adding the attribute default
Actions
You can add actions buttons to any resource, so for example if you want to resend email for a Reservation you can create a new action that will resend the email.
Just create a action on App\Front\Actions
, the structure is similar to the next file
Then add on the front resource (Reservation on this case) the next function
IndexActions
IndexAction works the same as Actions, the difference is that the button will appear at the beginning of the resource, Actions appears when you visit a data.
Pages
You can create pages on the system, on the routes you need to add it easily with Route::page('PageName', '/');
and execute the command php artisan front:page PageName
You will able to change the data on app/Front/PageName
Lenses
To create lenses just create the class on app/Front/Lenses/
folder. The lenses have the next structure:
Then you need to add the lense to the resource (In this case, the Fuel Front File)
The lenses have the same functionality as the Front Resources, so you customize fully the way it works.
Customizing the theme
Sidebar
You can customize the sidebar of the Front Panel editing the file on resources/front/sidebar
Support us
Weblabor is a web design agency based in México. You'll find an overview of all our open source projects on our website.
Does your business depend on our contributions? Reach out and support us All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
- Support us on Patreon - https://www.patreon.com/weblabormx
- Support us with a Paypal donation - https://paypal.me/weblabormx
All versions of laravel-front with dependencies
laracasts/flash Version >=3
laravelcollective/html Version >=5
opis/closure Version ^3.1
laravel/framework Version >5.5
weblabormx/file-modifier Version *
intervention/image Version >=2.5