Berkarar/plugins/tps/shops/Plugin.php

57 lines
1.9 KiB
PHP
Raw Normal View History

2022-08-28 19:50:26 +00:00
<?php namespace Tps\Shops;
use System\Classes\PluginBase;
2022-09-13 14:01:10 +00:00
use Tps\Shops\Models\Report;
use ZipArchive;
2022-08-28 19:50:26 +00:00
class Plugin extends PluginBase
{
public function registerComponents()
{
}
public function registerSettings()
{
}
2022-09-13 14:01:10 +00:00
// 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.');
// }
// }
// });
// });
// }
2022-08-28 19:50:26 +00:00
}