Couldn't figure out how to get the old value of a custom attachment from certain model ,
i added the Attachable trait , and the attachments is working and i can get the default old values using Upload::value("attachment")
but i added a foreign key in my post model to set a default image ( featured image ) us the Cropper field but i can't preview it , apparently the Cropper::value() accepts the attachment url , and i couldn't link it to a relationship ( hasOne ) .
this is how i did resolve but it seems like a bad workaround :
PostResource
private $post;
public function __construct(Request $request)
{
$this->post = (static::$model)::findOrFail($request->id);
}
Couldn't figure out how to get the old value of a custom attachment from certain model , i added the Attachable trait , and the attachments is working and i can get the default old values using
Upload::value("attachment")
but i added a foreign key in my post model to set a default image ( featured image ) us the Cropper field but i can't preview it , apparently the Cropper::value() accepts the attachment url , and i couldn't link it to a relationship ( hasOne ) .
this is how i did resolve but it seems like a bad workaround :
PostResource
is there another way to do it? should i add this change by default in the resource class to always get the model instance from the url param?