nhayder
254
6
Laravel

2 Mutators in 1 model ??? is posible

Posted 2 months ago by nhayder

Hi, i'm in this situation where i'm accessing same model mutator from 2 different end points, so i need to make different mutator for every endpoint.

// this is the current mutator that i already have it fetches the code DB column

    public function getEmbedAttribute($value)
    {
        $info = Embed::create($value);

        return $info->code;

    }

the other mutator should fetches image instead of code,

    public function getEmbedAttribute($value)
    {
        $info = Embed::create($value);

        return $info->image;

    }

Any ideas ????

Please sign in or create an account to participate in this conversation.