laravel/admin encore in model form BelongsToMany relationship can not save file

63 Views Asked by At

Hi everyone i have 3 tables: post (id), post_files (post_id, file_id) and files(file_name (file path), type(image/ video)) and i am using laravel/admin encore to save file.

  • In model Post i define:
    public function files()
    {
        return $this->belongsToMany(File::class, 'post_files', 'post_id', 'file_id');
    }
  • In PostController i use: $form->image('files.file_name', trans('post.post_media_file'))->required();

when i save a post it said saving success and the post field are saving ok but the relationship tables (post, post_files) didn't save anything

Also when I check devtool network in the request sent i didn't saw file_name field but it is there i can add image and I'm sure the name file_name i already add too. post_file

I have try to read docs and use some others relationship saving field but it did not work. So can i ask you guys how to detect the problem here and the solution to solve it ?

0

There are 0 best solutions below