Skip to content

Commit

Permalink
WIP: add multilang system
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Dec 3, 2023
1 parent 099b150 commit 254d0b9
Show file tree
Hide file tree
Showing 39 changed files with 375 additions and 43 deletions.
2 changes: 1 addition & 1 deletion _ide_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!
*
Expand Down
86 changes: 86 additions & 0 deletions app/Http/Controllers/Admin/XlangController.php
Original file line number Diff line number Diff line change
@@ -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)
{
//
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function cat(Cat $cat, Request $request)
} 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){
Expand Down
85 changes: 85 additions & 0 deletions app/Http/Controllers/XlangController.php
Original file line number Diff line number Diff line change
@@ -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)
{
//
}
}
38 changes: 38 additions & 0 deletions app/Models/Xlang.php
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
|
*/

'locale' => 'fa',
'locale' => 'en',

/*
|--------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions database/factories/XlangFactory.php
Original file line number Diff line number Diff line change
@@ -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 [
//
];
}
}
37 changes: 37 additions & 0 deletions database/migrations/2022_05_27_004801_create_xlangs_table.php
Original file line number Diff line number Diff line change
@@ -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');
}
};
9 changes: 5 additions & 4 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ public function run()

$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,
Expand Down
26 changes: 26 additions & 0 deletions database/seeders/XlangSeeder.php
Original file line number Diff line number Diff line change
@@ -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();
}
}
10 changes: 10 additions & 0 deletions public/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/js/app.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion resources/js/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
2 changes: 1 addition & 1 deletion resources/js/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading

0 comments on commit 254d0b9

Please sign in to comment.