Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old value of Cropper on edit resource #68

Open
HijenHEK opened this issue May 19, 2022 · 0 comments
Open

Old value of Cropper on edit resource #68

HijenHEK opened this issue May 19, 2022 · 0 comments

Comments

@HijenHEK
Copy link

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);
    }
Cropper::make('featured_image')
                ->title('Featured  Image')
                ->width(500)
                ->height(300)
                ->horizontal()
                ->targetId()
                ->value( $this->post ? $this->post->featuredImage->url : true),

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant