Skip to content

Commit 34bd3ab

Browse files
committed
added application config
1 parent 795df8d commit 34bd3ab

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Coderstm\Models\File;
4+
use Coderstm\Models\AppSetting;
5+
use Illuminate\Http\UploadedFile;
6+
use Illuminate\Support\Facades\Schema;
7+
use Illuminate\Support\Facades\Storage;
8+
use Illuminate\Database\Schema\Blueprint;
9+
use Illuminate\Database\Migrations\Migration;
10+
11+
return new class extends Migration
12+
{
13+
/**
14+
* Run the migrations.
15+
*
16+
* @return void
17+
*/
18+
public function up()
19+
{
20+
AppSetting::create('config', [
21+
'lang' => 'en-US'
22+
]);
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
//
33+
}
34+
};

lib/helpers.php

+16
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,19 @@ function admin_notify($notification)
142142
])->notify($notification);
143143
}
144144
}
145+
146+
if (!function_exists('app_lang')) {
147+
function app_lang()
148+
{
149+
$langs = [
150+
'en-US' => 'en',
151+
'hi_IN' => 'hi',
152+
'fr' => 'fr',
153+
];
154+
155+
$config = app_settings('config');
156+
$lang = $config['lang'] ?? 'en-US';
157+
158+
return $langs[$lang];
159+
}
160+
}

src/CoderstmServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function boot()
5050
'Group' => 'Coderstm\Models\Group',
5151
]);
5252

53-
App::setLocale('hi');
53+
App::setLocale(app_lang());
5454

5555
Paginator::useBootstrapFive();
5656

src/Http/Controllers/ApplicationController.php

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public function getSettings($key)
3333
return response()->json(AppSetting::findByKey($key), 200);
3434
}
3535

36+
public function config()
37+
{
38+
return $this->getSettings('config');
39+
}
40+
3641
/**
3742
* Update settings for a key.
3843
*

src/Models/User.php

+3
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ public function scopeWhereDateColumn($query, $date = [], $column = 'created_at')
461461
if (isset($date['month'])) {
462462
$q->whereMonth($column, $date['month']);
463463
}
464+
if (isset($date['day'])) {
465+
$q->whereDay($column, $date['day']);
466+
}
464467
});
465468
}
466469

0 commit comments

Comments
 (0)