57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?php namespace Tps\Shops;
|
|
|
|
use System\Classes\PluginBase;
|
|
use Tps\Shops\Models\Report;
|
|
use ZipArchive;
|
|
|
|
class Plugin extends PluginBase
|
|
{
|
|
public function registerComponents()
|
|
{
|
|
}
|
|
|
|
public function registerSettings()
|
|
{
|
|
}
|
|
|
|
// public function boot() {
|
|
|
|
// Report::extend(function($model) {
|
|
// // for create time only
|
|
// $model->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.');
|
|
// }
|
|
// }
|
|
// });
|
|
// });
|
|
// }
|
|
}
|