Answers for "laravel model custom attribute"

PHP
8

laravel custom attributes

<?php
...

class Movie extends Model
{

    protected $appends = ['cover'];

    //define accessor
    public function getCoverAttribute()
    {
        return json_decode($this->InJson)->cover;
    }
}
Posted by: Guest on August-26-2021
0

laravel model set new attribute

public function getAvailabilityAttribute()
    {
        return $this->calculateAvailability();  
    }
Posted by: Guest on July-14-2021

Code answers related to "laravel model custom attribute"

Browse Popular Code Answers by Language