PHP code example of n7olkachev / laravel-accessors
1. Go to this page and download the library: Download n7olkachev/laravel-accessors 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/ */
n7olkachev / laravel-accessors example snippets
class User
{
use Accessors;
protected $name;
public function __construct($name)
{
$this->name = $name;
}
public function getNameAttribute()
{
return $this->name;
}
public function setNameAttribute($name)
{
$this->name = $name;
}
}
$user = new User('Nick');
echo $user->name; // calls getNameAttribute
$user->name = 'Not Nick' // calls setNameAttribute
class User
{
use Accessors;
}