src/Repositories/EloquentRepository.php
public function detachFile($page, $file)
    {
        $filesIds = $page->files->pluck('id')->toArray();
        $pivotData = [];
        $position = 1;
        foreach ($filesIds as $fileId) {
            if ($fileId != $file->id) {
                $pivotData[$fileId] = ['position' => $position++];
            }
        }
        $page->files()->sync($pivotData);
        $this->forgetCache();
    }
public function detachFile($page, $file)
    {
        $filesIds = $page->files->pluck('id')->toArray();
        $pivotData = [];
        $position = 1;
        foreach ($filesIds as $fileId) {
            if ($fileId != $file->id) {
                $pivotData[$fileId] = ['position' => $position++];
            }
        }
        $page->files()->sync($pivotData);
        $this->forgetCache();
    }
public function detachFile ( $ page , $ file ) { $ filesIds = $ page -> files -> pluck ( 'id' ) -> toArray ( ) ; $ pivotData = [ ] ; $ position = 1 ; foreach ( $ filesIds as $ fileId ) { if ( $ fileId != $ file -> id ) { $ pivotData [ $ fileId ] = [ 'position' => $ position ++ ] ; } } $ page -> files ( ) -> sync ( $ pivotData ) ; $ this -> forgetCache ( ) ; }
Remove files from model.
Remove files from model .