added tag translate name and model

pull/49/head
A1Gard 4 months ago
parent f936feb684
commit 1b0f113227

@ -0,0 +1,71 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Controllers\XController;
use App\Http\Requests\TagSaveRequest;
use Illuminate\Http\Request;
use Spatie\Tags\Tag;
class TagController extends XController
{
protected $cols = ['name', 'slug'];
protected $extra_cols = ['id'];
protected $searchable = ['name', 'slug'];
protected $listView = 'admin.tags.tag-list';
protected $buttons = [
];
public function __construct()
{
parent::__construct(Tag::class, TagSaveRequest::class);
}
protected function makeSortAndFilter()
{
if (!\request()->has('sort') || !in_array(\request('sort'), $this->cols)) {
$query = $this->_MODEL_::orderByDesc('id');
} else {
$query = $this->_MODEL_::orderBy(\request('sort'), \request('sortType', 'asc'));
}
foreach (\request()->input('filter', []) as $col => $filter) {
if (isJson($filter)) {
$vals = json_decode($filter);
if (count($vals) != 0) {
$query->whereIn($col, $vals);
}
} else {
$query->where($col, $filter);
}
}
if (mb_strlen(trim(\request()->input('q', ''))) > 0) {
$q = trim(json_encode(\request()->input('q', '')), ' "');
$q = str_replace('\\', '\\\\', $q);
foreach ($this->searchable as $col) {
$query->where(function ($query) use ($q) {
foreach ($this->searchable as $key => $col) {
if ($key === 0) {
$query->where($col, 'LIKE', '%' . $q . '%');
} else {
$query->orWhere($col, 'LIKE', '%' . $q . '%');
}
}
});
}
}
return $query;
}
}

@ -28,6 +28,7 @@ use Illuminate\Http\Request;
use App\Helper;
use Illuminate\Support\Facades\Artisan;
use Spatie\Image\Image as SpatieImage;
use Spatie\Tags\Tag;
use function App\Helpers\hasCreateRoute;
@ -53,6 +54,7 @@ class XLangController extends XController
State::class,
City::class,
Transport::class,
Tag::class,
];

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class TagSaveRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}

@ -0,0 +1,15 @@
@extends('admin.templates.panel-list-template')
@section('list-title')
<i class="ri-user-3-line"></i>
{{__("Tags list")}}
@endsection
@section('title')
{{__("Tags list")}} -
@endsection
@section('filter')
{{-- Other filters --}}
@endsection
@section('bulk')
{{-- <option value="-"> - </option> --}}
@endsection

@ -140,6 +140,14 @@
</a>
</li>
@endif
@if( auth()->user()->hasAnyAccess( 'tags' ))
<li>
<a href="{{route('admin.tag.index')}}">
<i class="ri-price-tag-3-line"></i>
{{__("Attachments")}}
</a>
</li>
@endif
</ul>
</li>
@endif

@ -66,6 +66,10 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::post('bulk', [\App\Http\Controllers\Admin\DiscountController::class, "bulk"])->name('bulk');
Route::get('trashed', [\App\Http\Controllers\Admin\DiscountController::class, "trashed"])->name('trashed');
});
Route::prefix('tags')->name('tag.')->group(
function () {
Route::get('', [\App\Http\Controllers\Admin\TagController::class, 'index'])->name('index');
});
Route::prefix('tickets')->name('ticket.')->group(
function () {
Route::get('', [\App\Http\Controllers\Admin\TicketController::class, 'index'])->name('index');

Loading…
Cancel
Save