bindEvent('model.beforeSave', function() use ($model) { // $records = \October\Rain\Database\Models\DeferredBinding::where([ // 'master_type' => 'Tps\Shops\Models\Report', // <- REPLACE WITH YOUR MODEL(ModelName) // "master_field" => "file", // <- REPLACE WITH ATTACHEMNT MODEL (gallery) // "slave_type" => "System\Models\File", // "session_key" => post('_session_key') // ])->get(); // foreach($records as $record) { // $fileRecord = \System\Models\File::find($record->slave_id); // // $fileRecord = \System\Models\File::find($this->id); // $zip = new ZipArchive(); // $status = $zip->open($fileRecord->getRealPath()); // if ($status !== true) { // throw new \Exception($status); // } // else{ // $storageDestinationPath= storage_path("app/uploads/unzip/"); // if (!\File::exists( $storageDestinationPath)) { // \File::makeDirectory($storageDestinationPath, 0755, true); // } // $zip->extractTo($storageDestinationPath); // $zip->close(); // // return back() // // ->with('success','You have successfully extracted zip.'); // } // } // }); // }); // } }