Note: The
master
branch and releases>=1.0
are for Laravel 5. Use the0.x
branch or~0.9
releases for Laravel 4.
Include the package:
composer require "cviebrock/eloquent-replaceable:~0.9"
Add the service provider to app/config.php
:
'providers' => [
'Cviebrock\EloquentReplaceable\ServiceProvider',
],
Publish the configuration:
php artisan config:publish "cviebrock/eloquent-replaceable"
Update app/config/packages/cviebrock/eloquent-replaceable/config.php
as needed (see the comment in the file for help).
$model = Model::find(1);
// echo the raw model attribute:
echo $model->some_attribute;
// echo the model attribute with all replacements handled:
echo $model->doReplacements('some_attribute');