use Illuminate\Database\Eloquent\Model;
use Igorwanbarros\CustomAccessorAndMutator\CustomAccessorsAndMutators;
class Order extends Model
{
use CustomAccessorsAndMutators;
protected $table = 'order';
protected $customAccessors = [
//attribute name you model => your default method for treating this type of data
'you_attribute_name' => '_yourMethodGet',
'you_other_attribute_name' => '_yourMethodGet',
];
protected $customMutators = [
'you_atribute_name' => '_yourMethodGet',
'you_other_atribute_name' => '_yourMethodGet',
];
protected function _youtMethodGet($value)
{
//you logic here
return $value;
}
protected function _youtMethodSet($value)
{
//you logic here
return $value;
}
}
class ModelBase extends Model
{
use CustomAccessorsAndMutators
}
class Order extends Model
{
protected $table = 'order';
protected $customAccessors = [
'you_attribute_name' => '_yourMethodGet',
];
protected $customMutators = [
'you_attribute_name' => '_yourMethodGet',
];
protected function _youtMethodGet($value)
{
//you logic here
return $value;
}
protected function _youtMethodSet($value)
{
//you logic here
return $value;
}
}
namespace App\FormatAccessorsAndMutators;
use Igorwanbarros\CustomAccessorAndMutator\FormatAccessorAndMutator;
class MoneyFormatAccessorsAndMutators implements FormatAccessorAndMutator
{
public static function get($value)
{
//you logic here
return $value;
}
public static function set($value)
{
//you logic here
return $value;
}
}
use Illuminate\Database\Eloquent\Model;
use Igorwanbarros\CustomAccessorAndMutator\CustomAccessorsAndMutators;
use App\FormatAccessorsAndMutators\MoneyFormatAccessorsAndMutators;
class Order extends Model
{
use CustomAccessorsAndMutators;
protected $table = 'order';
protected $customAccessors = [
'you_attribute_name' => MoneyFormatAccessorsAndMutators::class,
'you_other_attribute_name' => MoneyFormatAccessorsAndMutators::class,
];
protected $customMutators = [
'you_atribute_name' => MoneyFormatAccessorsAndMutators::class,
'you_other_atribute_name' => MoneyFormatAccessorsAndMutators::class,
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.