WIP: add multilang system

main
A1Gard 5 months ago
parent 099b150992
commit 254d0b9683

@ -4,7 +4,7 @@
/**
* A helper file for Laravel, to provide autocomplete information to your IDE
* Generated for Laravel 9.52.14.
* Generated for Laravel 9.52.16.
*
* This file should not be included in your code, only analyzed by your IDE!
*

@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Xlang;
use Illuminate\Http\Request;
class XlangController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function show(Xlang $xlang)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function edit(Xlang $xlang)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Xlang $xlang)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function destroy(Xlang $xlang)
{
//
}
}

@ -109,6 +109,7 @@ class WebsiteController extends Controller
} else {
$q = $q->orderByDesc('sell_count');
}
if (isset($request->meta) && isset($request->meta['material'])){
// dd(array_column(json_decode($request->meta['material'],true),'value'));
if (count(json_decode($request->meta['material'],true) ) > 0){

@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers;
use App\Models\Xlang;
use Illuminate\Http\Request;
class XlangController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function show(Xlang $xlang)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function edit(Xlang $xlang)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Xlang $xlang)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Xlang $xlang
* @return \Illuminate\Http\Response
*/
public function destroy(Xlang $xlang)
{
//
}
}

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Xlang
*
* @property int $id
* @property string $name
* @property string $tag
* @property int $rtl
* @property int $is_default
* @property string|null $img
* @property int $sort
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Database\Factories\XlangFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Xlang newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Xlang newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Xlang query()
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereImg($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereIsDefault($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereRtl($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereSort($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereTag($value)
* @method static \Illuminate\Database\Eloquent\Builder|Xlang whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Xlang extends Model
{
use HasFactory;
}

@ -92,7 +92,7 @@ return [
|
*/
'locale' => 'fa',
'locale' => 'en',
/*
|--------------------------------------------------------------------------

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Xlang>
*/
class XlangFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
//
];
}
}

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('xlangs', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('tag',7);
$table->boolean('rtl')->default(false);
$table->boolean('is_default')->default(false);
$table->string('img')->nullable()->default(null);
$table->tinyInteger('sort')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('xlangs');
}
};

@ -31,13 +31,14 @@ class DatabaseSeeder extends Seeder
$this->call([
UserSeeder::class,
XlangSeeder::class,
CategorySeeder::class,
CatSeeder::class,
CustomerSeeder::class,
PostSeeder::class,
MenuSeeder::class,
PropSeeder::class,
ProductSeeder::class,
// PostSeeder::class,
// MenuSeeder::class,
// PropSeeder::class,
// ProductSeeder::class,
// InvoiceSeeder::class,
// SliderSeeder::class,
SettingSeeder::class,

@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use App\Models\Xlang;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class XlangSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
$lang = new Xlang();
$lang->tag = 'fa';
$lang->rtl = true;
$lang->is_default = true;
$lang->name = 'پارسی';
$lang->save();
}
}

@ -1134,3 +1134,13 @@ nav a {
padding: 4px 2rem;
background: rgba(30, 144, 255, 0.26);
}
.form-check-label {
padding-right: 1.25rem;
padding-left: 1.25rem;
}
.category-control li input {
margin-right: 5px;
margin-top: 1px;
}

File diff suppressed because one or more lines are too long

@ -14,10 +14,16 @@ jQuery(function () {
if (confirm('Are sure?')) {
let self = this;
axios.post($("#rem-menu").val() + '/' + $(this).data('menuableid')).then(function () {
$(self).slideUp();
$(self).slideUp();
});
}
});
window.addEventListener('load', function () {
if (!isRtl) {
document.querySelector('body').style.direction = 'ltr';
}
})
// );
// $("nav .current").closest('li').click();
});

@ -6,7 +6,7 @@ $(function () {
CKEDITOR.replace('description', {
filebrowserUploadUrl: xupload,
filebrowserUploadMethod: 'form',
contentsLangDirection: 'rtl'
contentsLangDirection: isRtl?'rtl':'ltr'
});
CKEDITOR.instances.description.on('change',function () {
$("#description").val(CKEDITOR.instances.description.getData());

@ -228,3 +228,14 @@ nav {
padding: 4px 2rem;
background: rgba(30, 144, 255, 0.26);
}
// fix rtl and ltr
.form-check-label {
padding-right: 1.25rem;
padding-left: 1.25rem;
}
.category-control li input{
margin-right: 5px;
margin-top: 1px;
}

@ -15,8 +15,8 @@
{{__('New product category')}}
@else
{{__('Edit product category')}}: {{$ccat->name}}
<img src="{{$ccat->thumbUrl()}}" class="x64 float-right" alt="">
<img src="{{$ccat->backUrl()}}" class="x64 float-right" alt="">
<img src="{{$ccat->thumbUrl()}}" class="x64 float-start" alt="">
<img src="{{$ccat->backUrl()}}" class="x64 float-start" alt="">
{{-- {{$ccat->imgUrl()}}--}}
@endif
</h1>

@ -26,7 +26,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.cat.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.cat.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -62,7 +62,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.customer.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.customer.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -29,7 +29,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.discount.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.discount.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -48,7 +48,7 @@
</th>
<th>
{{__("Action")}}
{{-- <a href="{{route('admin.invoice.create')}}" class="btn btn-success float-right"><i--}}
{{-- <a href="{{route('admin.invoice.create')}}" class="btn btn-success float-start"><i--}}
{{-- class="fa fa-plus"></i></a>--}}
</th>
</tr>

@ -45,7 +45,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.product.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.product.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -3,7 +3,7 @@
@section('content')
<div class="container">
<h5 class="text-center"> {{__("Properties list")}}
<a class="btn btn-primary float-right" href="{{route('admin.props.create')}}">
<a class="btn btn-primary float-start" href="{{route('admin.props.create')}}">
<i class="fa fa-plus"></i>
</a>
</h5>

@ -39,7 +39,7 @@
</th>
<th>
{{__("Action")}}
{{-- <a href="{{route('admin.invoice.create')}}" class="btn btn-success float-right"><i--}}
{{-- <a href="{{route('admin.invoice.create')}}" class="btn btn-success float-start"><i--}}
{{-- class="fa fa-plus"></i></a>--}}
</th>
</tr>

@ -23,7 +23,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.transport.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.transport.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -61,7 +61,7 @@
@if (old('active',$adv->active??0) != 0)
checked
@endif
class="float-left ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
class="float-end ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
value="">
</div>
</div>

@ -7,7 +7,7 @@
<div class="container">
<h1>
{{__("Advertise list")}}
<a href="{{route('admin.adv.create')}}" class="btn btn-success float-right">
<a href="{{route('admin.adv.create')}}" class="btn btn-success float-start">
{{__("New Advertise")}}
</a>
</h1>
@ -52,7 +52,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.adv.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.adv.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -23,7 +23,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.category.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.category.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -79,7 +79,7 @@
@if (old('active',$clip->active??0) != 0)
checked
@endif
class="float-left ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
class="float-end ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
value="">
</div>
</div>

@ -7,7 +7,7 @@
<div class="container">
<h1>
{{__("Clip list")}}
<a href="{{route('admin.clip.create')}}" class="btn btn-success float-right">
<a href="{{route('admin.clip.create')}}" class="btn btn-success float-start">
{{__("New Clip")}}
</a>
</h1>
@ -46,7 +46,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.clip.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.clip.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -5,12 +5,12 @@
<div class="card">
<div class="card-header">
<h3 class="text-center">
<a class="btn btn-dark float-right" href="{{route('admin.home.nav',[$ny,$nm])}}">
<a class="btn btn-dark float-start" href="{{route('admin.home.nav',[$ny,$nm])}}">
{{__("Next")}}
<i class="fa fa-arrow-left"></i>
</a>
{{$dt->PDate('Y F',$time)}}
<a class="btn btn-dark float-left" href="{{route('admin.home.nav',[$py,$pm])}}">
<a class="btn btn-dark float-end" href="{{route('admin.home.nav',[$py,$pm])}}">
<i class="fa fa-arrow-right"></i>
{{__("Previous")}}
</a>

@ -40,7 +40,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.gallery.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.gallery.create')}}" class="btn btn-success float-end"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -58,7 +58,7 @@
@if (old('active',$poll->active??0) != 0)
checked
@endif
class="float-left ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
class="float-end ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
value="">
</div>
</div>

@ -7,7 +7,7 @@
<div class="container">
<h1>
{{__("Poll list")}}
<a href="{{route('admin.poll.create')}}" class="btn btn-success float-right">
<a href="{{route('admin.poll.create')}}" class="btn btn-success float-start">
{{__("New Poll")}}
</a>
</h1>
@ -46,7 +46,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.poll.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.poll.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -111,7 +111,7 @@
</label>
<input name="is_breaking" type="checkbox" id="is_breaking"
class="float-left ml-4 mt-1 form-check-inline @error('is_breaking') is-invalid @enderror"
class="float-end ml-4 mt-1 form-check-inline @error('is_breaking') is-invalid @enderror"
placeholder="{{__('Is breaking news?')}}"
@if (old('is_breaking',$posts->is_breaking??0) != 0)
checked
@ -126,7 +126,7 @@
{{__('Pin')}}
</label>
<input name="is_pinned" type="checkbox" id="is_pinned"
class="float-left ml-4 mt-1 form-check-inline @error('is_pinned') is-invalid @enderror"
class="float-end ml-4 mt-1 form-check-inline @error('is_pinned') is-invalid @enderror"
placeholder="{{__('Is pinned news?')}}"
@if (old('is_pinned',$posts->is_pinned??0) != 0)
checked

@ -40,7 +40,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.post.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.post.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -57,7 +57,7 @@
@if (old('active',$slider->active??0) != 0)
checked
@endif
class="float-left ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
class="float-end ml-4 mt-1 form-check-inline @error('active') is-invalid @enderror"
value="">
</div>
</div>

@ -8,7 +8,7 @@
<div class="container">
<h1>
{{__("Slider list")}}
<a href="{{route('admin.slider.create')}}" class="btn btn-success float-right">
<a href="{{route('admin.slider.create')}}" class="btn btn-success float-start">
{{__("New Slider")}}
</a>
</h1>
@ -44,7 +44,7 @@
</th>
<th>
{{__("Action")}}
<a href="{{route('admin.slider.create')}}" class="btn btn-success float-right"><i
<a href="{{route('admin.slider.create')}}" class="btn btn-success float-start"><i
class="fa fa-plus"></i></a>
</th>
</tr>

@ -7,7 +7,7 @@
<div class="container">
<h1>
{{__("User list")}}
<a href="{{route('admin.user.create')}}" class="btn btn-success float-right">
<a href="{{route('admin.user.create')}}" class="btn btn-success float-start">
{{__("New user")}}
</a>
</h1>

@ -7,8 +7,16 @@
<script src="{{ asset('vendor/starter-kit/js/manifest.js') }}" ></script>
<script src="{{ asset('vendor/starter-kit/js/vendor.js') }}" defer ></script>
<script src="{{ asset('vendor/starter-kit/js/app.js') }}" defer ></script>
@yield('header-content')
<script>
@php
$lang = \App\Models\Xlang::where('is_default',true)->first();
@endphp
var isRtl = false;
@if($lang !== null && $lang->rtl)
isRtl = true;
@endif
</script>
@yield('header-content')
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
@ -34,7 +42,7 @@
<input type="search" value="" placeholder="{{__("Search in all panel")}}" class="form-control"/>
</form>
<div class="col-md-3">
<div class="m-2 float-right">
<div class="m-2 float-start">
{{__("Welcome")}}: {{auth()->user()->name}}
</div>
</div>

Loading…
Cancel
Save