typerocket / laravel
Makes form building and model binding a breeze.
Installs: 3 737
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=5.5.9
- gumlet/php-image-resize: 2.0.*
Requires (Dev)
- phpunit/phpunit: ~4.0
- dev-master
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.23
- v2.1.22
- v2.1.21
- v2.1.20
- v2.1.19
- v2.1.18
- v2.1.17
- v2.1.16
- v2.1.15
- v2.1.14
- v2.1.13
- v2.1.12
- v2.1.11
- v2.1.10
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-RC2
- v2.0.0-RC1
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- 1.0.1
- v1.0.1-beta
- v1.0.0-beta
This package is auto-updated.
Last update: 2024-11-06 09:15:34 UTC
README
Originally for WordPress, TypeRocket makes building advanced forms and fields easy for Laravel too.
See http://typerocket.com for documentation (mainly for WordPress).
Installing
composer require typerocket/laravel
Laravel Service Providers make a way for extending Laravel. TypeRocket Laravel 2.0 is a service provider for Laravel. In your config/app.php
file add:
'providers' => [ // Other Service Providers TypeRocket\Service::class, ],
Then form the command line:
php artisan vendor:publish --provider="TypeRocket\Service"
You can now access the config/typerocket.php
.
Finally, add uploads to public folder. From your site root directory run:
ln -s ../storage/uploads uploads
Note: Routes, views, and controller will be adding for you.
JS and CSS init
In blade templates such master templates.
{!! \TypeRocket\Assets::getHeadString() !!}
{!! \TypeRocket\Assets::getFooterString() !!}
Adding assets
$paths = Config::getPaths(); // type ( js || css), id, path Assets::addToFooter('js', 'typerocket-core', $paths['urls']['js'] . '/typerocket.js'); Assets::addToHead('js', 'typerocket-global', $paths['urls']['js'] . '/global.js');
Forms
// model, action ( create || update ), id, path $form = new \TypeRocket\Form('Post', 'update', $id, '/posts/' . $id);
<div class="typerocket-container"> {!! $form->open() !!} {!! $form->text('title')->setLabel('Post Title') !!} {!! $form->checkbox('publish')->setText('Published') !!} {!! $form->close('Submit') !!} </div>
Request Old Input
To load old input into the form set the request.
class PostController extends Controller { public function create(Request $request) { $form = new \TypeRocket\Form('Post', 'create', null, '/posts/'); $form->setRequest($request); // set request return view('posts.create', ['form' => $form]); } }
Validate
class PostController extends Controller { public function store(Request $request) { $tr = $request->input('tr'); $validator = \Validator::make($tr, [ 'title' => 'required|max:255' ]); if ($validator->fails()) { return redirect("posts/create") ->withErrors($validator) ->withInput(); } $post = new Fabric(); $post->title = $tr['title']; $post->save(); header('Location: /posts/'); } }
Matrix route.
Working with matrix fields the service provider will add this for you.
Route::post('matrix_api/{group}/{type}', function($group, $type) { (new TypeRocket\Matrix())->route($group, $type); });
CSFR for matrix
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; class VerifyCsrfToken extends BaseVerifier { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'matrix_api/*' // added ]; }
Matrix Assets
Assets will not be loaded form fields because the view is already loaded. Include the possible assets in the controller.
For example a Matrix field that uses an image field will need to include image.js
.
$paths = \TypeRocket\Config::getPaths(); \TypeRocket\Assets::addToFooter('js', 'typerocket-image', $paths['urls']['js'] . '/image.js');
Media
Typerocket Media uses https://github.com/eventviva/php-image-resize to create thumbnails.
Unsplash
To enable, set the typerocket.media.unsplash.enabled
to true
, and set the the Unsplash client ID in typerocket.media.unsplash.client_id
.
To add the Unsplash button and modal anywhere, use the custom Blade directive @tr_unsplash
.