PHP code example of creativeorange / laravel-injectable
1. Go to this page and download the library: Download creativeorange/laravel-injectable 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/ */
creativeorange / laravel-injectable example snippets
$question = \App\Models\Question::first();
$question->name->inject('company_name', 'Acme Inc.');
// or to use multiple:
$question->name->inject(['company_name', 'Acme Inc.', 'another_var' => 'Another val']);
echo $question->name; // will output the name with the variables replaced
echo $question->description; // will output the original text, without any replacements; for example: This is the description for company :company_name
$question = \App\Models\Question::first();
$question->inject('company_name', 'Acme Inc.');
// or to use multiple:
$question->inject(['company_name', 'Acme Inc.', 'another_var' => 'Another val']);
echo $question->name; // will output the name with the variables replaced
echo $question->description; // will output the description with the variables replaced
// Use the alias
\LaravelInjectable::set('company_name', 'Acme Inc.');
// Or directly use the facade
\CreativeOrange\LaravelInjectable\Facades\LaravelInjectable::set('company_name', 'Acme Inc.');
// Or via the app method
app(\Creativeorange\LaravelInjectable\LaravelInjectable::class)->set('company_name', 'Acme Inc.');
// Or set multiple vars at once
\LaravelInjectable::set(['company_name', 'Acme Inc.', 'another_var' => 'Another val']);
\LaravelInjectable::set('company_name', 'Acme Inc.')->set('another_var', 'Another val');
$question = \App\Models\Question::first();
echo $question->name; // will output the name with the variables replaced
echo $question->description; // will output the description with the variables replaced
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.