Skip to content

Commit

Permalink
Update To Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
xuandung38 committed Apr 18, 2022
1 parent 7fccda7 commit b682f2f
Show file tree
Hide file tree
Showing 444 changed files with 1,894 additions and 36,964 deletions.
8 changes: 8 additions & 0 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use App\Models\Role;
use App\Models\Setting;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -260,3 +261,10 @@ function binding_meta_seo($data, $route)
return $meta;
}
}

if(!function_exists('site_setting')){
function site_setting(string $key){
$setting = Setting::where('key',$key)->first();
return $setting?->value;
}
}
68 changes: 39 additions & 29 deletions app/Http/Controllers/Admin/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,43 @@

class SettingController extends Controller
{
/**
* @return Factory|View
*/
public function index()
{
if (Gate::denies(Permissions::SETTING)) {
return abort(403, 'Không có quyền');
}

return view('admin.screens.setting', [
'setting' => Setting::first(),
]);
}

/**
* @param Setting $setting
* @param UpdateSettingRequest $request
*
* @return JsonResponse
*/
public function update(Setting $setting, UpdateSettingRequest $request)
{
if (Gate::denies(Permissions::SETTING)) {
return abort(403, 'Không có quyền');
}

$setting->update($request->parameters());
return response()->json($setting);
}
/**
* @return Factory|View
*/
public function index()
{
if (Gate::denies(Permissions::SETTING)) {
return abort(403, 'Không có quyền');
}

$settings = Setting::all();

$arrSettings = [];
foreach ($settings as $setting) {
$arrSettings[$setting->key] = $setting->value;
}

return view('admin.screens.setting', [
'setting' => $arrSettings,
]);
}

/**
* @param Setting $setting
* @param UpdateSettingRequest $request
*
* @return JsonResponse
*/
public function update(UpdateSettingRequest $request)
{
if (Gate::denies(Permissions::SETTING)) {
return abort(403, 'Không có quyền');
}
$settings = $request->parameters() ?? [];

foreach ($settings as $key => $setting) {
Setting::where('key', $key)->update(['value' => $setting]);
}
return response()->json($settings);
}
}
5 changes: 2 additions & 3 deletions app/Http/ViewComposers/Admin/IndexComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ class IndexComposer
public function compose(View $view)
{
$adminRoles = Role::whereGuard('admin')->get();
$admin = admin();

$view->with([
'_user' => $admin,
'_availableRoles' => admin_available_roles($admin, $adminRoles),
'_admin' => admin(),
'_availableRoles' => admin_available_roles(admin(), $adminRoles),
'_adminRoles' => $adminRoles,
'_notifications' => []
]);
Expand Down
71 changes: 5 additions & 66 deletions app/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,81 +7,20 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
* App\Models\Setting
*
* @property int $id
* @property string $logo
* @property string $name
* @property string $address
* @property string $phone
* @property string $hotline
* @property string $email
* @property string $color
* @property string $title
* @property string $keyword
* @property string $description
* @property string $thumbnail
* @property mixed|null $slider
* @property string|null $instagram
* @property string|null $facebook
* @property string|null $youtube
* @property string|null $twitter
* @property string|null $spotify
* @property string|null $soundcloud
* @property string|null $gg_analytic_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static Builder|Setting newModelQuery()
* @method static Builder|Setting newQuery()
* @method static Builder|Setting query()
* @method static Builder|Setting whereAddress($value)
* @method static Builder|Setting whereColor($value)
* @method static Builder|Setting whereCreatedAt($value)
* @method static Builder|Setting whereDescription($value)
* @method static Builder|Setting whereEmail($value)
* @method static Builder|Setting whereFacebook($value)
* @method static Builder|Setting whereGgAnalyticId($value)
* @method static Builder|Setting whereHotline($value)
* @method static Builder|Setting whereId($value)
* @method static Builder|Setting whereInstagram($value)
* @method static Builder|Setting whereKeyword($value)
* @method static Builder|Setting whereLogo($value)
* @method static Builder|Setting whereName($value)
* @method static Builder|Setting wherePhone($value)
* @method static Builder|Setting whereSlider($value)
* @method static Builder|Setting whereSoundcloud($value)
* @method static Builder|Setting whereSpotify($value)
* @method static Builder|Setting whereThumbnail($value)
* @method static Builder|Setting whereTitle($value)
* @method static Builder|Setting whereTwitter($value)
* @method static Builder|Setting whereUpdatedAt($value)
* @method static Builder|Setting whereYoutube($value)
* @method static first()
* @mixin Eloquent
* @property float $tax_rate
* @method static Builder|Setting whereTaxRate($value)
*/

class Setting extends Model
{
/** @var string $table */
protected $table = 'setting';
protected $table = 'settings';

/** @var array $hidden */
protected $hidden = [];

/** @var array $fillable */
protected $fillable = [
'logo',
'name',
'address',
'phone',
'hotline',
'color',
'title',
'keyword',
'description',
'thumbnail'
'key',
'value',
'status',
];

}
1 change: 1 addition & 0 deletions app/Providers/ViewComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function boot()


// Admin
// view()->composer(['admin.layouts.*'], AdminCPS\IndexComposer::class);
view()->composer(['admin.screens.*'], AdminCPS\IndexComposer::class);
view()->composer(['admin.screens.admins'], AdminCPS\AdminComposer::class);
view()->composer(['admin.screens.files'], AdminCPS\FileComposer::class);
Expand Down
Loading

0 comments on commit b682f2f

Please sign in to comment.