File manager - Edit - /var/www/html/spdc/api/app/Models/Answer.php
Back
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; class Answer extends Model { use HasFactory; use HasUuids; protected $fillable = [ 'value', 'answerable_type', 'answerable_id' ]; /** * Saving and returning propely if value is an array . * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ protected function value(): Attribute { return Attribute::make( get: fn ($value) => (json_decode($value)) ? json_decode($value) : $value, set: fn ($value) => (is_array($value)) ? json_encode($value) : $value, ); } public function answerable() { return $this->morphTo(); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings