Download the PHP package maxfactor/support without Composer
On this page you can find all versions of the php package maxfactor/support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maxfactor/support
More information about maxfactor/support
Files in maxfactor/support
Package support
Short Description Support and helpers for Laravel PHP based projects
License MIT
Informations about the package support
Maxfactor Laravel Support
Authors:
- Marco Mark
- Jacob Walters
- Tristan Ward
- Sam Wrigley
- Daniel Crewdson
Overview
A set of helper methods and classes commonly used in Web projects
Models
More generic helpers which apply to more than just front-end facing web pages.
Active State
Ensure records can be active or inactive (e.g. Draft like state). Add the trait to your model and the fields to your migration.
Prevent access to inactive models
By default, the config option canViewInactive
is set to true
, so all requests to view content will be authorised. To prevent unauthorised access to content that isn't active, either register a global viewInactive
gate in the service provider, or on a per-model basis via a Policy. If the Gate fails, the package will abort a 503
error.
Featured State
Allow records to be featured.
Sorting Order
Allow records to be ordered/sorted (sequentially). Add the trait and sortable contract to your model.
Migration helper ...
A query scope is included so you can access sorted results without manually defining the orderBy
.
Webpage
A set of helpers and traits relating to public facing web pages.
Typically any model which interfaces with the front-end views should extend the Maxfactor\Support\Webpage\Model
instead of the default Eloquent Model. This will ensure other Traits can be correctly initialised.
INPORTANT: In order to try and create some consistancy, the main Model passed into a view should always be called $page
. This makes it much easier to include default behaviour inside layouts and other shared components without explicitly passing in values.
Meta (incl. Browser Title)
Add the Maxfactor\Support\Webpage\Traits\HasMetaAttributes
trait to your model and include the migrations by adding the meta field(s). This will include the correct database column and default to cover:
- h1
- browserTitle
- metaDescription
- navTitle
Include this in your layout to render the browser title
And this is a pre-made component to render the meta description
Additional Meta Fields in Nova
You can pass in additional meta fields into the MetaAttributes::make()
function, to display your own fields in the 'Meta Attributes' panel that this package creates.
Slugs
Add the Maxfactor\Support\Webpage\Traits\HasSlug
trait to your model if you want the route helper to use the slug
column in your database to identify records. (E.g. /blog/article/foo
instead of /blog/article/1
).
Within your migrations you can simply use the slug helper to add the correct column to your tables. $table->slug()
.
Breadcrumbs
Use the Maxfactor\Support\Webpage\Traits\HasBreadcrumbs
trait (already included if you are using the Webpage Model). Overload the seeds()
method to return custom breadcrumbs and/or use the seed()
method to push any breadcrumbs you require into the parent seed to add additional breadcrumbs.
Inside your blade view, render the breadcrumbs @include('maxfactor::components.breadcrumb', ['seed' => $page->breadcrumbs])
. Replace the view with your own if required.
Setting a default 'Home' breadcrumb
To change the default Home breadcrumb, you can set the homeBreadcrumb
config value.
Canonicals
Include the MustHaveCanonical
trait which by default will return the current url but you typically would specify your own.
This can be done on the Model ...
Or inline (e.g. in the controller). This will take precedence over the baseCanonical
.
Inside the head of your blade layout (or view) render the canonical meta field.
The Maxfactor facade also includes an additional helper method which can be used to deal with Querystring parameters in the canonical url. The urlWithQuerystring
method accepts the desired url and a string or regular expression to filter which parameters to include in the output. The query values are taken from the current request query, even though the destination url doesn't have to match this. Here's an example of how this could be used to include pagination.
Sitemap
To generate a sitemap simply create a new Command and Extend the MakeSitemap
command in this package. Then add it to your console kernel and schedule as required. Here is the template to use as starting point.
Enforce Domain Names and SSL
Search engines should only index content at a single URL, as such your website should only be served on it's primary domain. We provide a middleware to handle this as well as allowing for multiple domains (if you are running domain specific routes).
Add the Maxfactor\Support\Webpage\Middleware\ForceDomain::class
to your web middleware group in the Kernel.
By default it will use the Scheme (HTTP/HTTPS) and domain name form your app.url
config value. You can specify additional domains in your .env
.
Furthermore you can specify which response codes should be run through the domain validator in the maxfactor-support
config.
Password protection
If you want to protected access to your application, or certain routes, on specific environments (e.g. staging) you can include the Maxfactor\Support\Webpage\Middleware\EnvironmentAuth::class
middleware, either on entire groups or specific routes as required by naming the middleware in the Kernel.
This will require the visitor to login with a valid user account on environments specified in the auth.php
config (Defaults to staging
).
Search functionality
There are a number of useful tools here for implementing search functionality. Our recommended approach is to use nicolaslopezj/searchable as it works straight on database queries without requiring any third party indexing systems. It is also very easy to customise and define rules to determine the most relevant search results. However, you should be able to use Scout or another search implementation. The only functionality imposed is that a search
method exists on the model and ideally a relevance
attribute is available on the model in order to sort mixed results.
Making Models Searchable
Aside from following the search providers instructions (e.g. nicolaslopezj/searchable) or Scout, you need to implement a Contract and Trait to add the required functionality.
Search Facade
So in your SearchController
, or where-ever you are performing the search, use the provided Maxfactor\Support\Facades\Search
facade to return a Collection of results. This will be a combination of all results for any models included in the search. You may pass in any Eloquent\Builder
instance or Eloquent\Model
.
Optionally you can paginate the result which uses the Laravel Paginator.
Displaying results
To display the results, loop over the returned Collection and display the results attributes.
All versions of support with dependencies
symfony/intl Version ^4.0
dereuromark/media-embed Version ^0.4.1
spatie/laravel-view-components Version ^1.1
laravelium/sitemap Version ^2.0|^3.0|^6.0|^7.0
dannyvankooten/laravel-vat Version ^2.0.4