2017 © Pedro Peláez
 

library laraphrases

Inline phrase editing for Laravel apps

image

orkhan/laraphrases

Inline phrase editing for Laravel apps

  • Thursday, April 3, 2014
  • by orkhan
  • Repository
  • 2 Watchers
  • 4 Stars
  • 3 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laraphrases!

Build Status, (*1)

Laraphrases, (*2)

Laraphrases is a package for live editing phrases on websites., (*3)

Installation

Require the package in your composer.json file, (*4)

{
    "require": {
        "orkhan/laraphrases": "dev-master"
    },
}

Afterwards, run composer update from your command line., (*5)

Then, add following to the list of service providers in app/config/app.php, (*6)

'Orkhan\Laraphrases\LaraphrasesServiceProvider',

and followings to the list of aliases, (*7)

'Laraphrase' => 'Orkhan\Laraphrases\Facades\Laraphrase',
'Phrase' => 'Orkhan\Laraphrases\Facades\Phrase',

Run the install command which will migrate database and publishes configs, views and assets., (*8)

artisan laraphrases:install

Setup

The artisan command will generate phrase.php configuration file in app/config/packages/orkhan/laraphrases folder. Here you will need to implement the can_edit filter. Use this to hook-up your existing user authentication system to work with Laraphrases., (*9)

For example:, (*10)

    'can_edit' => function() {
        return Sentry::check() && Sentry::getUser()->hasAccess('laraphrases') ? true : false
    },

Include the token meta at the head of your application layout file., (*11)

<meta name="_token" content="{{ Session::token() }}">

Include the laraphrase blade file at the top of your application layout file., (*12)

@if(Laraphrase::canEditPhrase())
    @include('laraphrases::laraphrase')
@endif

Include the required jQuery library and Laraphrases javascript file:, (*13)

{{ Laraphrase::js() }}

Include the required stylesheet file:, (*14)

{{ Laraphrase::css() }}

How to use Laraphrases?

You can start adding new phrases by simply adding them in your view file:, (*15)

{{ Laraphrase::get('phrase-key', 'phrase-value-optional-otherwise-value-same-with-key') }}

Aside from editing phrases (basically, Laravel translations) you can also edit model attributes inline. Use the same Laraphrase::get method, with the first attribute being the record in question, and the second one the attribute you wish to make editable:, (*16)

{{ Laraphrase::get($post, 'title') }}

In the above example, $post is the record with a title attribute., (*17)

Security

Since Laraphrases can be used to update any attribute in any table, special care must be taken into consideration from a security standpoint., (*18)

By default, Laraphrases doesn't allow updating of any attribute apart from 'Phrase' => ['value']. To be able to work with other attributes, you need to whitelist them., (*19)

In the app/config/packages/orkhan/laraphrases/phrase.php file you can whitelist your model attributes like this:, (*20)

    'white_list' => [
        'Phrase' => ['value'],
        'Post' => ['title', 'summary'],
    ],

Credits

Laraphrases is maintained and sponsored by ORIGAMI AGENCY., (*21)

ORIGAMI AGENCY, (*22)

Laraphrases leverages part ZenPen., (*23)

License

Laraphrases © 2014 ORIGAMI AGENCY. It is free software, and may be redistributed under the terms specified in the LICENSE file., (*24)

The Versions

03/04 2014

dev-master

9999999-dev

Inline phrase editing for Laravel apps

  Sources   Download

The Requires

 

by Orkhan Maharramli

laravel inline eloquent phrase contenteditable phrases laraphrases