<commit_before><?php
namespace Minhbang\LaravelImage\Controllers;

use Minhbang\LaravelKit\Extensions\BackendController as Controller;
use Minhbang\LaravelKit\Traits\Controller\QuickUpdateActions;
use Minhbang\LaravelImage\ImageModel;
use Illuminate\Http\Request;
use Conner\Tagging\Tag;
use Datatable;
use Image;
use Html;

/**
 * Class BackendController
 *
 * @package Minhbang\LaravelImage\Controllers
 */
class BackendController extends Controller
{
    use QuickUpdateActions;

    /**
     * BackendController constructor.
     */
    public function __construct()
    {
        parent::__construct(config('image.middlewares.backend'));
    }

    /**
     * Danh sách hình ảnh theo định dạng của Datatables.
     *
     * @param \Illuminate\Http\Request $request
     *
     * @return \Datatable JSON
     */
    public function data(Request $request)
    {
        /** @var ImageModel $query */
        $query = ImageModel::orderUpdated();
        if ($request->has('search_form')) {
            $query = $query
                ->searchWhereBetween('images.created_at', 'mb_date_vn2mysql')
                ->searchWhereBetween('images.updated_at', 'mb_date_vn2mysql');
        }
        return Datatable::query($query)
            ->addColumn(
                'index',
                function (ImageModel $model) {
                    return $model->id;
                }
            )
            ->addColumn(
                'title',
                function (ImageModel $model) {
                    return $model->present()->block;
                }
            )
            ->addColumn(
                'dimensions',
                function (ImageModel $model) {
                    return $model->present()->dimensions;
                }
            )
            ->addColumn(
                'mime',
                function (ImageModel $model) {
                    return $model->present()->mime;
                }
            )
            ->addColumn(
                'size',
                function (ImageModel $model) {
                    return $model->present()->size;
                }
            )
            ->addColumn(
                'used',
                function (ImageModel $model) {
                    return $model->used;
                }
            )
            ->addColumn(
                'actions',
                function (ImageModel $model) {
                    return Html::tableActions(
                        'backend/image',
                        $model->id,
                        trans('image::common.images') . ($model->title ? ": {$model->title}" : ''),
                        trans('image::common.images'),
                        [
                            'renderShow'   => 'modal-large',
                            'renderDelete' => (int)$model->used ? 'disabled' : 'link',
                            'titleEdit'    => trans('image::common.replace'),
                        ]
                    );
                }
            )
            ->searchColumns('images.title', 'images.mime')
            ->make();
    }

    /**
     * @return \Illuminate\View\View
     * @throws \Exception
     */
    public function index()
    {
        $tableOptions = [
            'id'        => 'image-manage',
            'row_index' => true,
            'class'     => 'table-image',
        ];
        $options = [
            'aoColumnDefs' => [
                ['sClass' => 'min-width', 'aTargets' => [0, 6]],
                ['sClass' => 'min-width text-center', 'aTargets' => [3]],
                ['sClass' => 'min-width text-right', 'aTargets' => [2, 4, 5]],
            ],
        ];
        $table = Datatable::table()
            ->addColumn(
                '#',
                trans('image::common.column.image'),
                trans('image::common.column.dimensions'),
                trans('image::common.column.mime'),
                trans('image::common.column.size'),
                trans('image::common.column.used'),
                trans('common.actions')
            )
            ->setOptions($options)
            ->setCustomValues($tableOptions);
        $this->buildHeading(trans('image::common.library'), 'fa-image', ['#' => trans('image::common.library')]);
        $allTags = implode(',', Tag::lists('name')->all());
        return view('image::index', compact('tableOptions', 'options', 'table', 'allTags'));
    }

    /**
     * @return \Illuminate\View\View
     * @throws \Laracasts\Presenter\Exceptions\PresenterException
     */
    public function upload()
    {
        $this->buildHeading(
            trans('image::common.upload_title'),
            'fa-upload',
            [
                route('backend.image.index') => trans('image::common.library'),
                '#'                          => trans('common.upload'),
            ]
        );
        $all_tags = implode(',', Tag::lists('name')->all());
        return view('image::upload', compact('all_tags'));<commit_msg>update tags all<commit_after><?php
namespace Minhbang\LaravelImage\Controllers;

use Minhbang\LaravelKit\Extensions\BackendController as Controller;
use Minhbang\LaravelKit\Traits\Controller\QuickUpdateActions;
use Minhbang\LaravelImage\ImageModel;
use Illuminate\Http\Request;
use Conner\Tagging\Tag;
use Datatable;
use Image;
use Html;

/**
 * Class BackendController
 *
 * @package Minhbang\LaravelImage\Controllers
 */
class BackendController extends Controller
{
    use QuickUpdateActions;

    /**
     * BackendController constructor.
     */
    public function __construct()
    {
        parent::__construct(config('image.middlewares.backend'));
    }

    /**
     * Danh sách hình ảnh theo định dạng của Datatables.
     *
     * @param \Illuminate\Http\Request $request
     *
     * @return \Datatable JSON
     */
    public function data(Request $request)
    {
        /** @var ImageModel $query */
        $query = ImageModel::orderUpdated();
        if ($request->has('search_form')) {
            $query = $query
                ->searchWhereBetween('images.created_at', 'mb_date_vn2mysql')
                ->searchWhereBetween('images.updated_at', 'mb_date_vn2mysql');
        }
        return Datatable::query($query)
            ->addColumn(
                'index',
                function (ImageModel $model) {
                    return $model->id;
                }
            )
            ->addColumn(
                'title',
                function (ImageModel $model) {
                    return $model->present()->block;
                }
            )
            ->addColumn(
                'dimensions',
                function (ImageModel $model) {
                    return $model->present()->dimensions;
                }
            )
            ->addColumn(
                'mime',
                function (ImageModel $model) {
                    return $model->present()->mime;
                }
            )
            ->addColumn(
                'size',
                function (ImageModel $model) {
                    return $model->present()->size;
                }
            )
            ->addColumn(
                'used',
                function (ImageModel $model) {
                    return $model->used;
                }
            )
            ->addColumn(
                'actions',
                function (ImageModel $model) {
                    return Html::tableActions(
                        'backend/image',
                        $model->id,
                        trans('image::common.images') . ($model->title ? ": {$model->title}" : ''),
                        trans('image::common.images'),
                        [
                            'renderShow'   => 'modal-large',
                            'renderDelete' => (int)$model->used ? 'disabled' : 'link',
                            'titleEdit'    => trans('image::common.replace'),
                        ]
                    );
                }
            )
            ->searchColumns('images.title', 'images.mime')
            ->make();
    }

    /**
     * @return \Illuminate\View\View
     * @throws \Exception
     */
    public function index()
    {
        $tableOptions = [
            'id'        => 'image-manage',
            'row_index' => true,
            'class'     => 'table-image',
        ];
        $options = [
            'aoColumnDefs' => [
                ['sClass' => 'min-width', 'aTargets' => [0, 6]],
                ['sClass' => 'min-width text-center', 'aTargets' => [3]],
                ['sClass' => 'min-width text-right', 'aTargets' => [2, 4, 5]],
            ],
        ];
        $table = Datatable::table()
            ->addColumn(
                '#',
                trans('image::common.column.image'),
                trans('image::common.column.dimensions'),
                trans('image::common.column.mime'),
                trans('image::common.column.size'),
                trans('image::common.column.used'),
                trans('common.actions')
            )
            ->setOptions($options)
            ->setCustomValues($tableOptions);
        $this->buildHeading(trans('image::common.library'), 'fa-image', ['#' => trans('image::common.library')]);
        $allTags = implode(',', Tag::lists('name')->all());
        return view('image::index', compact('tableOptions', 'options', 'table', 'allTags'));
    }

    /**
     * @return \Illuminate\View\View
     * @throws \Laracasts\Presenter\Exceptions\PresenterException
     */
    public function upload()
    {
        $this->buildHeading(
            trans('image::common.upload_title'),
            'fa-upload',
            [
                route('backend.image.index') => trans('image::common.library'),
                '#'                          => trans('common.upload'),
            ]
        );
        $all_tags = ImageModel::allTagNames();
        return view('image::upload', compact('all_tags'));
{'fraction_non_alphanumeric': 0.1432004806729421, 'fraction_numerical': 0.0016022431403965552, 'mean_word_length': 1.414068165337201, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 100, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1066331', 'n_tokens_mistral': 2687, 'n_tokens_neox': 2566, 'n_words': 424}