Skip to content
Discussion options

You must be logged in to vote

Hi mate @alancwoo , try this one

so we have Issue model, create a laravel accessor inside your Issue model, you can add this function

public function getCleanYearAttribute()
{ 
    return explode('-',$this->year)[0];
}

protected function year(): Attribute
{
    return Attribute::make(
        get: fn (string $value) => $value.'-'.$this->month,
    );
}

and your IssueCrudController should be like this

//this is for setupListOperation
CRUD::column('clean_year'); //change year to clean_year

//this is for setupCreateOperation
CRUD::field('year')->type('month')->on('saving', function ($entry) {
    $explodeData = explode('-', $entry->year);
    $entry->year = $explodeData[0];
    $entry->month

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alancwoo
Comment options

Answer selected by alancwoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants