Last active
August 29, 2015 14:05
-
-
Save ollieread/84586f9cf7d44664b0c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Ollieread\Toolkit\ToolkitServiceProvider' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Ollieread\Toolkit\Repositories; | |
class BaseRepository | |
{ | |
public function setModel($model); | |
public function setValidator($validator); | |
public function setContext($context); | |
public function make(); | |
public function all($paginate = 0); | |
public function lists($value, $key = null, $select = false, $id = 0); | |
public function get($id); | |
public function getBy($field, $value); | |
public function create(array $data); | |
public function update($id, array $data); | |
public function delete($id); | |
public function with($with); | |
public function wipe(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"require": { | |
"ollieread/toolkit": "1.0.0" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
/* | |
* This is the path for your routes directory, it may be app/routes or it may be | |
* app/Project/Routes, whatever. | |
*/ | |
'routes_directory' => app_path() . '/routes/', | |
/* | |
* Whether or not to use the default error handler for ValidationException, this | |
* will basically catch validation errors and redirect back with input and errors. | |
* | |
* Set to false if you wish to define your own. | |
*/ | |
'catch_validation' => true, | |
/* | |
* Whether or not updates should be tidied up. This will basically go through the dat passed | |
* to BaseRepository::tidy($model, $data) and compare against the value in the model, anything | |
* that matches is stripped from the array. | |
*/ | |
'pre_update_clean' => true, | |
/* | |
* Whether or not to remove empty values from an update, set to false if you wish to write empty values | |
* to your database. | |
*/ | |
'pre_update_empty' => true | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$repository->setContext($user->company->posts()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::error(function (ValidationException $e) { | |
// Here we check the referer so that we don't get 'unable to redirect to empty url' errors. | |
$referer = Request::server('HTTP_REFERER'); | |
if (!empty($referer)) { | |
// Send the input and the errors | |
return Redirect::back()->withInput()->withErrors($e->getErrors()); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php artisan config:publish ollieread/toolkit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::file($prefix, $file[, $attributes]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::file('/user', 'user.php', [ | |
'namespace' => 'MyApp\Controllers\User', | |
'before' => 'auth' | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/', [ | |
'as' => 'user.index', | |
'uses' => 'UserController@index' | |
]); | |
Route::get('/{id}', [ | |
'as' => 'user.show', | |
'uses' => 'UserController@show' | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Ollieread\Toolkit\Validators\BaseValidator; | |
class MyValidator extends BaseValidator | |
{ | |
public static $rules = [ | |
'create' => [], | |
'update' => [] | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment