WIP: add multilang system

main
A1Gard 6 months ago
parent 099b150992
commit 254d0b9683

@ -4,7 +4,7 @@
/** /**
* A helper file for Laravel, to provide autocomplete information to your IDE * 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! * 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 { } else {
$q = $q->orderByDesc('sell_count'); $q = $q->orderByDesc('sell_count');
} }
if (isset($request->meta) && isset($request->meta['material'])){ if (isset($request->meta) && isset($request->meta['material'])){
// dd(array_column(json_decode($request->meta['material'],true),'value')); // dd(array_column(json_decode($request->meta['material'],true),'value'));
if (count(json_decode($request->meta['material'],true) ) > 0){ 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([ $this->call([
UserSeeder::class, UserSeeder::class,
XlangSeeder::class,
CategorySeeder::class, CategorySeeder::class,
CatSeeder::class, CatSeeder::class,
CustomerSeeder::class, CustomerSeeder::class,
PostSeeder::class, // PostSeeder::class,
MenuSeeder::class, // MenuSeeder::class,
PropSeeder::class, // PropSeeder::class,
ProductSeeder::class, // ProductSeeder::class,
// InvoiceSeeder::class, // InvoiceSeeder::class,
// SliderSeeder::class, // SliderSeeder::class,
SettingSeeder::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; padding: 4px 2rem;
background: rgba(30, 144, 255, 0.26); 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?')) { if (confirm('Are sure?')) {
let self = this; let self = this;
axios.post($("#rem-menu").val() + '/' + $(this).data('menuableid')).then(function () { 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(); // $("nav .current").closest('li').click();
}); });

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

@ -228,3 +228,14 @@ nav {
padding: 4px 2rem; padding: 4px 2rem;
background: rgba(30, 144, 255, 0.26); 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')}} {{__('New product category')}}
@else @else
{{__('Edit product category')}}: {{$ccat->name}} {{__('Edit product category')}}: {{$ccat->name}}
<img src="{{$ccat->thumbUrl()}}" class="x64 float-right" alt=""> <img src="{{$ccat->thumbUrl()}}" class="x64 float-start" alt="">
<img src="{{$ccat->backUrl()}}" class="x64 float-right" alt=""> <img src="{{$ccat->backUrl()}}" class="x64 float-start" alt="">
{{-- {{$ccat->imgUrl()}}--}} {{-- {{$ccat->imgUrl()}}--}}
@endif @endif
</h1> </h1>

@ -26,7 +26,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -62,7 +62,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -29,7 +29,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -48,7 +48,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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>--}} {{-- class="fa fa-plus"></i></a>--}}
</th> </th>
</tr> </tr>

@ -45,7 +45,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -3,7 +3,7 @@
@section('content') @section('content')
<div class="container"> <div class="container">
<h5 class="text-center"> {{__("Properties list")}} <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> <i class="fa fa-plus"></i>
</a> </a>
</h5> </h5>

@ -39,7 +39,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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>--}} {{-- class="fa fa-plus"></i></a>--}}
</th> </th>
</tr> </tr>

@ -23,7 +23,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -61,7 +61,7 @@
@if (old('active',$adv->active??0) != 0) @if (old('active',$adv->active??0) != 0)
checked checked
@endif @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=""> value="">
</div> </div>
</div> </div>

@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<h1> <h1>
{{__("Advertise list")}} {{__("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")}} {{__("New Advertise")}}
</a> </a>
</h1> </h1>
@ -52,7 +52,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -23,7 +23,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -79,7 +79,7 @@
@if (old('active',$clip->active??0) != 0) @if (old('active',$clip->active??0) != 0)
checked checked
@endif @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=""> value="">
</div> </div>
</div> </div>

@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<h1> <h1>
{{__("Clip list")}} {{__("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")}} {{__("New Clip")}}
</a> </a>
</h1> </h1>
@ -46,7 +46,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -5,12 +5,12 @@
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h3 class="text-center"> <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")}} {{__("Next")}}
<i class="fa fa-arrow-left"></i> <i class="fa fa-arrow-left"></i>
</a> </a>
{{$dt->PDate('Y F',$time)}} {{$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> <i class="fa fa-arrow-right"></i>
{{__("Previous")}} {{__("Previous")}}
</a> </a>

@ -40,7 +40,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -58,7 +58,7 @@
@if (old('active',$poll->active??0) != 0) @if (old('active',$poll->active??0) != 0)
checked checked
@endif @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=""> value="">
</div> </div>
</div> </div>

@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<h1> <h1>
{{__("Poll list")}} {{__("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")}} {{__("New Poll")}}
</a> </a>
</h1> </h1>
@ -46,7 +46,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -111,7 +111,7 @@
</label> </label>
<input name="is_breaking" type="checkbox" id="is_breaking" <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?')}}" placeholder="{{__('Is breaking news?')}}"
@if (old('is_breaking',$posts->is_breaking??0) != 0) @if (old('is_breaking',$posts->is_breaking??0) != 0)
checked checked
@ -126,7 +126,7 @@
{{__('Pin')}} {{__('Pin')}}
</label> </label>
<input name="is_pinned" type="checkbox" id="is_pinned" <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?')}}" placeholder="{{__('Is pinned news?')}}"
@if (old('is_pinned',$posts->is_pinned??0) != 0) @if (old('is_pinned',$posts->is_pinned??0) != 0)
checked checked

@ -40,7 +40,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -57,7 +57,7 @@
@if (old('active',$slider->active??0) != 0) @if (old('active',$slider->active??0) != 0)
checked checked
@endif @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=""> value="">
</div> </div>
</div> </div>

@ -8,7 +8,7 @@
<div class="container"> <div class="container">
<h1> <h1>
{{__("Slider list")}} {{__("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")}} {{__("New Slider")}}
</a> </a>
</h1> </h1>
@ -44,7 +44,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("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> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<h1> <h1>
{{__("User list")}} {{__("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")}} {{__("New user")}}
</a> </a>
</h1> </h1>

@ -7,8 +7,16 @@
<script src="{{ asset('vendor/starter-kit/js/manifest.js') }}" ></script> <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/vendor.js') }}" defer ></script>
<script src="{{ asset('vendor/starter-kit/js/app.js') }}" defer ></script> <script src="{{ asset('vendor/starter-kit/js/app.js') }}" defer ></script>
<script>
@yield('header-content') @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 --> <!-- CSRF Token -->
<meta name="csrf-token" 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"/> <input type="search" value="" placeholder="{{__("Search in all panel")}}" class="form-control"/>
</form> </form>
<div class="col-md-3"> <div class="col-md-3">
<div class="m-2 float-right"> <div class="m-2 float-start">
{{__("Welcome")}}: {{auth()->user()->name}} {{__("Welcome")}}: {{auth()->user()->name}}
</div> </div>
</div> </div>

Loading…
Cancel
Save