PHP code example of ghunti / laravel-base
1. Go to this page and download the library: Download ghunti/laravel-base library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ghunti / laravel-base example snippets
protected $middleware = [
...<other middleware>...,
'Ghunti\LaravelBase\Middleware\ShareMessagesFromSession',
];
use Ghunti\LaravelBase\Exception\ValidatorException;
...
try {
Validator::make(
Input::all(),
array(
'name' => array(
' ->withInput()
->withErrors($e->getValidator());
}
return Redirect::route('some_route')
->withMessages(
array('success' => 'Something worked for a change!!!')
);
//or
return Redirect::route('some_route')
->withMessages(
array('error' => 'Crappy as usual!')
);
$messageMap = array(
'information' => 'info',
'success' => 'success',
'warning' => 'warning',
'error' => 'danger',
);
try {
Validator::make(
Input::all(),
Model::getValidationRules()
)
->passOrFail();
...
//or
try {
$model = $this->repository->findOrFail($id);
Validator::make(
Input::all(),
$model->getValidationRules()
)
->passOrFail();
...
public function allOrderedByName($direction = 'asc')
{
return $this->model->orderBy('name', $direction)->get();
}