2017 © Pedro Peláez
 

library laravel-utilities

Utilities for Laravel 5

image

vi-kon/laravel-utilities

Utilities for Laravel 5

  • Friday, May 1, 2015
  • by vincekovacs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,323 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 20 % Grown

The README.md

Laravel 5 Utilities

Utilities for Laravel 5. View helpers and other usefull classes., (*1)

Table of contents

Known issues

None, (*2)


Back to top, (*3)

Todo

  • Fix incoming bugs
  • Finish documentation

Back to top, (*4)

Changes

Version 2.1, (*5)

  • The Seeder class functionality replaced by ConsoleProgressbar trait

Version 2.0, (*6)

  • Laravel 5 support (requirement)
  • Controller class removed (Laravel 5 supports validation via FormRequest classes)
  • New middleware features (IsAjax)
  • Code optimization with Laravel 5 new features and conventions

Back to top, (*7)

Installation

Base

To your composer.json file add following lines:, (*8)

// to your "require" object
"vi-kon/laravel-utilities": "2.*"

In your Laravel 5 project add following lines to app.php:, (*9)

// to your providers array
'ViKon\Utilities\UtilitiesServiceProvider',

Middleware

To use middleware class assigned to route need to assign short-hand key to middleware property of your app/Providers/RouteServiceProvider class:, (*10)

// to your middleware array
'ajax' => 'ViKon\Utilities\Middleware\IsAjax',

Back to top, (*11)

Views


Back to top, (*12)

html5-layout

There are two templates. One for Blade template engine and one for Smarty template engine., (*13)

Note: html5-layout.tpl requires Smarty functions implemented in vi-kon/laravel-smarty-view package., (*14)

Avalaible blocks / sections:

Name Description
author Author metadata
body Empty block in body root
description Description metadata
head Empty block for other head stuff
scripts Scripts at after closing body tag
scripts-head Empty block to include header scripts
styles Empty block to include stylesheets
title Page title
viewport Viewport meta data

Block / section definitions:, (*15)

author
<!-- ... other head stuff ... -->
<meta name="author" content="@yield('author', 'Kovács Vince')"/>
<!-- ... other head stuff ... -->
<!-- ... other head stuff ... -->
<meta name="author" content="{block name="author"}Kovács Vince{/block}">
<!-- ... other head stuff ... -->
body
<body>
    @yield('body')
</body>
<body>
    {block name="body"}{/block}
</body>
description
<!-- ... other head stuff ... -->
<meta name="description" content="@yield('description')"/>
<!-- ... other head stuff ... -->

or, (*16)

<!-- ... other head stuff ... -->
<meta name="description" content="{block name="description"}{/block}">
<!-- ... other head stuff ... -->
<head>
    <!-- ... other head stuff ... -->
    @yield('head')
</head>

or, (*17)

<head>
    <!-- ... other head stuff ... -->
    {block name="head"}{/block}
</head>
scripts
        <!-- ... body inner ... -->
    </body>
    @yield('scripts')
</html>

or, (*18)

        <!-- ... body inner ... -->
    </body>
    {block name="scripts"}{/block}
</html>
scripts-head
<head>
    <!-- ... other head stuff ... -->
    @yield('scripts-head')
    <!-- ... other head stuff ... -->
</head>

or, (*19)

<head>
    <!-- ... other head stuff ... -->
    {block name="scripts-head"}{/block}
    <!-- ... other head stuff ... -->
</head>
styles
<head>
    <!-- ... other head stuff ... -->
    @yield('styles')
    <!-- ... other head stuff ... -->
</head>

or, (*20)

<head>
    <!-- ... other head stuff ... -->
    {block name="styles"}{/block}
    <!-- ... other head stuff ... -->
</head>
title
<!-- ... other head stuff ... -->
<title>@yield('title', 'HTML 5 Layout')</title>
<!-- ... other head stuff ... -->

or, (*21)

<!-- ... other head stuff ... -->
<title>{block name="title"}HTML 5 Layout{/block}</title>
<!-- ... other head stuff ... -->
viewport
<head>
    <!-- ... other header stuff ... -->
    @section('viewport')
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    @show
    <!-- ... other header stuff ... -->
</head>

or, (*22)

<head>
    <!-- ... other header stuff ... -->
    {block name="viewport"}
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    {/block}
    <!-- ... other header stuff ... -->
</head>

Back to top, (*23)

Usage

Example "app-layout.tpl"
{extends file="view:utilities::html5-layout"}


{block name="title"}{strip}
    {lang}app.title{/lang}
{/strip}{/block}


{block name="description"}{strip}
    {lang}app.description{/lang}
{/strip}{/block}


{block name="styles"}{strip}
    {html_style _url="vendor/bootstrap/css/bootstrap.min.css"}
    {html_style _url="vendor/bootstrap-tokenfield/bootstrap-tokenfield.min.css"}
{/strip}{/block}


{block name="scripts-head" append}{strip}
    {html_script _url="vendor/jquery/jquery-2.1.0.min.js"}
    {html_script _url="vendor/bootstrap/js/bootstrap.min.js"}
    {html_script _url="vendor/bootstrap-tokenfield/bootstrap-tokenfield.min.js"}
{/strip}{/block}


{block name="scripts" append}{strip}
    {html_script _url="js/bootstrap-setup.js"}
{/strip}{/block}


{block name="body"}{strip}


{* Page menu *}
<div class="container"> {* Block container for subpage content *} {block name="container"}{/block} </div> {/strip}{/block}

Back to top, (*25)

Classes

  • Migration - helper methods for database migration

Back to top, (*26)

Traits

ConsoleProgress trait

This trait help display a progressbar on console:, (*27)

Output, (*28)

############--------------------------------------  24.54% (124,752/508,331)

Usage, (*29)

// Initialize progressbar
$this->initProgressbar();
// Reset progress and output a message
$this->startProgress('Seed agt_agent_types table');
// Set progressbar elements
$this->setProgressMax(12);

// ...

// Make step in progressbar
$this->progress();

Back to top, (*30)

Middleware

Utilities middleware classes allow different features., (*31)

  • IsAjax - check if current request is ajax request or not

Back to top, (*32)

IsAjax middleware

Check if current request is ajax request or not. If request is not ajax request, then throws NotFoundHttpException exception., (*33)

Usage

$options = [
    'middleware' => 'ajax',
];
Route::get('URL', $options);

Back to top, (*34)

Helpers

Helper functions are shortcuts or aliases for app functions and methods., (*35)

json_response function

json_response function is alias for new JsonResponse., (*36)


Back to top, (*37)

License

This package is licensed under the MIT License, (*38)

The Versions

01/05 2015

dev-master

9999999-dev https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 5

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

01/05 2015

v2.2.0

2.2.0.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 5

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

28/03 2015

v2.1.0

2.1.0.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 5

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

28/03 2015

dev-develop

dev-develop https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 5

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

02/03 2015

v2.0.0

2.0.0.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 4

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

08/11 2014

4.2.x-dev

4.2.9999999.9999999-dev https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 4

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

08/11 2014

v1.0.6

1.0.6.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 4

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

15/08 2014

v1.0.5

1.0.5.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 4

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

21/07 2014

4.1.x-dev

4.1.9999999.9999999-dev

  Sources   Download

The Requires

 

by Kovács Vince

21/07 2014

v1.0.4

1.0.4.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 4

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

21/07 2014

v1.0.3

1.0.3.0 https://github.com/vi-kon/laravel-utilities

Utilities for Laravel 4

  Sources   Download

MIT

The Requires

 

by Kovács Vince

laravel utilities

17/06 2014

v1.0.2

1.0.2.0

  Sources   Download

The Requires

 

by Kovács Vince

08/06 2014

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

by Kovács Vince

23/05 2014

v1.0.0

1.0.0.0

  Sources   Download

The Requires

 

by Kovács Vince