You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
866 B
39 lines
866 B
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Client extends Model
|
|
{
|
|
protected $fillable = ['name', 'cell_number', 'birth_date', 'business_id'];
|
|
public $timestamps = false;
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($model) {
|
|
$model->created_at = $model->freshTimestamp();
|
|
});
|
|
}
|
|
|
|
public function setBirthDateAttribute($value)
|
|
{
|
|
if ($value) {
|
|
$this->attributes['birth_date'] = \Carbon\Carbon::createFromFormat('Y-m-d', $value)->toDateTimeString();
|
|
}
|
|
}
|
|
|
|
public function setDetailsAttribute($value)
|
|
{
|
|
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public function getDetailsAttribute()
|
|
{
|
|
return json_decode($this->attributes['details']);
|
|
}
|
|
|
|
}
|