1. Go to this page and download the library: Download jgrossi/laravel-mutable 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/ */
jgrossi / laravel-mutable example snippets
use Jgrossi\Mutable\Mutable;
class User extends Eloquent
{
use Mutable;
}
use App\Models\Mutators\UserMutator;
use Jgrossi\Mutable\Mutable;
class User extends Eloquent
{
use Mutable;
protected $mutator = UserMutator::class;
}
namespace App\Models\Mutators;
use Carbon\Carbon;
use Jgrossi\Mutable\Mutator;
class UserMutator extends Mutator
{
public function firstName($value)
{
return ucfirst($value);
}
public function createdAt(Carbon $date)
{
return $date->format('Y-m-d');
}
}
class FooController extends Controller
{
public function show($id)
{
$user = User::findOrFail($id);
return $user; // returns the changed User as array
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.