<commit_before><?php

namespace App\Http\Sections\Storages;

use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Storage as LaravelStorage;
use App\Events\DeleteFromStorageEvent;
use SleepingOwl\Admin\Contracts\Display\DisplayInterface;
use SleepingOwl\Admin\Contracts\Form\FormInterface;
use SleepingOwl\Admin\Section;

use AdminColumn;
use AdminDisplay;
use AdminForm;
use AdminFormElement;
use SleepingOwl\Admin\Contracts\Initializable;

/**
 * Class Product
 *
 * @property \App\Models\Storages\Storage $model
 *
 * @see http://sleepingowladmin.ru/docs/model_configuration_section
 */
class Storage extends Section
{
    protected $model = \App\Models\Storages\Storage::class;
    /**
     * @see http://sleepingowladmin.ru/docs/model_configuration#ограничение-прав-доступа
     *
     * @var bool
     */
    protected $checkAccess = false;

    /**
     * @var string
     */
    protected $title = 'Изображения';

    /**
     * @var string
     */
    protected $alias = 'storages/storage';

    /**
     * @return DisplayInterface
     */
    public function onDisplay()
    {
        return AdminDisplay::datatables()/*->with('users')*/
        ->setHtmlAttribute('class', 'table-primary')
            ->setColumns(
                AdminColumn::link('name', 'Назавние'),
                AdminColumn::image('url', 'Изображение')
                    ->setHtmlAttribute('class', 'text-center')
                    ->setWidth('200px'),
                // todo:сделать редактирование по месту
                AdminColumn::text('enable', 'Активность')->setWidth('10px')
            )->paginate(20);
    }

    /**
     * @param int $id
     *
     * @return FormInterface
     */
    public function onEdit($id)
    {
        if( Input::has('user_id') || Input::has('order_id') || Input::has('product_id') || Input::has('category_id') ){
            echo 'Нихуя все норм';
            return AdminForm::panel()->addBody([
                AdminFormElement::images('images', 'Images')
                    ->setUploadPath(function(\Illuminate\Http\UploadedFile $file) {
                        dd($file);
                        if(Input::has('user_id')){
                            return LaravelStorage::disk('storage')->url('users');
                        }else if(Input::has('order_id')){
                            return LaravelStorage::disk('storage')->url('orders');
                        }else if(Input::has('product_id')){
                            return LaravelStorage::disk('storage')->url('products');
                        }else if(Input::has('category_id')){
                            return LaravelStorage::disk('storage')->url('categories');
                        }
                    })
                ,
            ]);






        } else {
            return 'Нихуя нет';
        }

        return $form;
    }

    /**
     * @return FormInterface
     */
    public function onCreate()
    {
        return $this->onEdit(null);

    }

    /**
     * @return void
     */
    public function onDelete($id)
    {
        // todo: remove if unused
    }

    /**
     * @return void
     */<commit_msg>Попытка передачи аргументов get в форму<commit_after><?php

namespace App\Http\Sections\Storages;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Storage as LaravelStorage;
use App\Events\DeleteFromStorageEvent;
use SleepingOwl\Admin\Contracts\Display\DisplayInterface;
use SleepingOwl\Admin\Contracts\Form\FormInterface;
use SleepingOwl\Admin\Section;

use AdminColumn;
use AdminDisplay;
use AdminForm;
use AdminFormElement;
use SleepingOwl\Admin\Contracts\Initializable;

/**
 * Class Product
 *
 * @property \App\Models\Storages\Storage $model
 *
 * @see http://sleepingowladmin.ru/docs/model_configuration_section
 */
class Storage extends Section
{
    protected $model = \App\Models\Storages\Storage::class;
    /**
     * @see http://sleepingowladmin.ru/docs/model_configuration#ограничение-прав-доступа
     *
     * @var bool
     */
    protected $checkAccess = false;

    /**
     * @var string
     */
    protected $title = 'Изображения';

    /**
     * @var string
     */
    protected $alias = 'storages/storage';
    protected $request;
    public function __construct(Illuminate\Foundation\Application $act, Request $request)
    {
        $this->request = $request;
    }
    /**
     * @return DisplayInterface
     */
    public function onDisplay()
    {
        return AdminDisplay::datatables()/*->with('users')*/
        ->setHtmlAttribute('class', 'table-primary')
            ->setColumns(
                AdminColumn::link('name', 'Назавние'),
                AdminColumn::image('url', 'Изображение')
                    ->setHtmlAttribute('class', 'text-center')
                    ->setWidth('200px'),
                // todo:сделать редактирование по месту
                AdminColumn::text('enable', 'Активность')->setWidth('10px')
            )->paginate(20);
    }

    /**
     * @param int $id
     *
     * @return FormInterface
     */
    public function onEdit($id)
    {
        /*return AdminForm::panel()->addBody([
            AdminFormElement::images('string $key', 'string $label = null')
                ->setUploadPath(function(\Illuminate\Http\UploadedFile $file) {
                    //dd($file);
                    return 'storage/test'; // public/files
                })
                ->setUploadSettings([
                    'orientate' => [],
                    'resize' => [1280, null, function ($constraint) {
                        $constraint->upsize();
                        $constraint->aspectRatio();
                    }],
                    'fit' => [200, 300, function ($constraint) {
                        $constraint->upsize();
                        $constraint->aspectRatio();
                    }]
                ])
    	]);*/
        
       /* if( Input::has('user_id') || Input::has('order_id') || Input::has('product_id') || Input::has('category_id') ){
            echo 'Нихуя все норм';
        } else {
            echo 'Нихуя нет';
        }*/
        
        dd($this->request->url());
        if(Input::has('user_id')){
            $storage_path = LaravelStorage::disk('storage')->url('users');
            $this->storage_path = 'storage/users';
        }else if(Input::has('order_id')){
            $storage_path = LaravelStorage::disk('storage')->url('orders');
            $this->storage_path = 'storage/orders';
        }else if(Input::has('product_id')){
            $storage_path = LaravelStorage::disk('storage')->url('products');
            $this::$storage_path = 'storage/products';
        }else if(Input::has('category_id')){
            $storage_path = LaravelStorage::disk('storage')->url('categories');
            $this->storage_path = 'storage/categories';
        }

        /*}else{
            $storage_path = 'storage/test';
        }*/

        //dd($storage_path);
        //echo $storage_path;
        
        return AdminForm::panel()->addBody([
            AdminFormElement::images('images', 'Images')
                ->setUploadPath(function(\Illuminate\Http\UploadedFile $file){
                    if(Input::has('user_id')){
                        $storage_path = LaravelStorage::disk('storage')->url('users');
                    }else if(Input::has('order_id')){
                        $storage_path = LaravelStorage::disk('storage')->url('orders');
                    }else if(Input::has('product_id')){
                        $storage_path = LaravelStorage::disk('storage')->url('products');
                    }else if(Input::has('category_id')){
                        $storage_path = LaravelStorage::disk('storage')->url('categories');
                    }
                    return $storage_path;
                })
        ]);//->setAction('///googlr.ru');
    }

    /**
     * @return FormInterface
     */
    public function onCreate()
    {
        return $this->onEdit(null);

    }

    /**
     * @return void
     */
    public function onDelete($id)
    {
        // todo: remove if unused
    }

    /**
     * @return void
     */
{'fraction_non_alphanumeric': 0.14832886069773116, 'fraction_numerical': 0.002927543303244694, 'mean_word_length': 1.9303073624017155, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1442486', 'n_tokens_mistral': 2327, 'n_tokens_neox': 2280, 'n_words': 366}