Download the PHP package sinclairt/magic-views without Composer

On this page you can find all versions of the php package sinclairt/magic-views. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package magic-views

Magic Views

Magic views are a quick and simple way to implement crud views with as little or as much customisation as you want.

Installation

Add the service provider to your

Usage

Use the trait in your controller . As it stands, there are four views: index, create, edit, and show. The edit and update views require a variable, the index view requires a variable which should be an instance of . You can get a paginated object by using on the end of your query instead of i.e.

So an index method might look something like this:

Create like this...

Edit...

Show...

Assumptions

Magic Views makes a few assumptions to ensure your views are rendered with as little configuration as possible:

Settings

The index view will use the array and the array to decide which columns to show, but you can over ride this by setting the variable on your model:

The create and edit views use the array to display fields on the forms, these will default to text but you can over ride this by setting the variable on your model:

The key is the field name, the value is the field type.

Available field types:

You can extend this of course. Publish the assets, and then add your own blade in the partials/form directory and list the view in the fields array i.e. let's say you need a particular input when creating a user to assign roles, so you might have a and then set , hey presto your custom input is used in the form. This can be a quicker way of adding content to your forms then using the and hooks.

Field Notes

A select requires options, set the options by passing in a variable with the naming convention of fieldnameOptions i.e. role would be . This variable should an associative array with the key as the value to submit from the form i.e. the id, and the value as the display value for the option i.e. the name.

Buttons

On the index view are some buttons: show, edit, delete, and where your model uses soft deletes restore. By default all buttons are on ( when an object is trashed only restore and show are visible, and when its not restore is hidden, and edit and delete are added. You can configure the buttons you want to show by passing in a variable with the buttons you wish to show:

Sometimes you might want to disable the creation of objects, to do this set the variable and pass into your view and this will remove the new button.

The buttons can be formatted for a drop menu instead by setting the variable and passing into your view.

Display Values

There are three ways to approach this, as the value is, using Laravel's mutators, or using a Presenter. If your happy using the first two, then there is nothing more to do, then to read up on Eloquent Mutators if necessary. If you would like to use a Presenter, Magic Views will look for this so that it can be used in the view, it will assume the method on the presenter is the field name studly cased with 'present' in front i.e. becomes . If you would like to over ride the name of the presenter method to use then pass in a variable with the naming convention of presentFieldName i.e would become ; you would then pass this a string of the method name you would like to use e.g. let's say you want to present the username instead of the user_id, and your method on your presenter is you would do the following:

Now Magic Views will load the userName method instead.

If you do not have a method in the presenter for your method it will revert to the column value or mutator if set.

Other Variables

Magic views creates the following variables to put into the view, you can over ride them by passing in the variable(s) yourself:

Additional Content

Magic Views allows you to add additional content to both the forms and the pages. To do this, create a view and pass the view name to one of the following variables and inject to the view:

Further Customisation

You can further customise the views by changing the config values, the language values, or the editing the views themselves. To do this publish the assets of the package by running . All values displayed outside of model and presenter values, are passed through a language file first, there is an example for users in the language file already. The term sits on the top level of the array, but the fields of the , including the column names in the index view, sit inside the fields array. Placeholders can also be set here where applicable just add onto the end of the column/field name.

If you would like to swap out any of the partials for your own, you can change the value in the config file. You can also change the title tag, brand image, nav-links, form-action assumptions, and any breadcrumb prefix you may want i.e. home or dashboard.

There is also a fallback option for language files. If you supply a dot notation string to the method in Laravel and it doesn't find a value it will return the dot notation string ( ), the logic behind this is that it is easier to spot a missing language value if it is displayed like this. If you switch on the fallback (default is true), then it will find the last element in your dot notation and return that instead of the full string i.e. becomes . If want to turn this off, change the to . The method is if you would like to use in your own code.

Beyond this, you can edit the views themselves.

Finally

You can extend the Magic Views so long as you create them. For example, lets take a stats page for a user, create a , which might extend the (or use the config value ), and add a section with your content inside. Now you can call in your controller. Or, if you publish the assets ( ), and put your view inside you can call

There are two yield methods in the layout for code to go into the and the should you need it.


All versions of magic-views with dependencies

PHP Build Version
Package Version
Requires illuminate/view Version ^5.1
illuminate/support Version ^5.1
illuminate/contracts Version ^5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sinclairt/magic-views contains the following files

Loading the files please wait ....