Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) shuvroroy <shuvro.nsu.cse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Help Desk

<p>
<a href="https://laravel.com"><img alt="Laravel v8.x" src="https://img.shields.io/badge/Laravel-v8.x-FF2D20?style=for-the-badge&logo=laravel"></a>
<a href="https://laravel-livewire.com"><img alt="Livewire v2.x" src="https://img.shields.io/badge/Livewire-v2.x-FB70A9?style=for-the-badge"></a>
<a href="https://filamentphp.com/"><img alt="Filament v2.x" src="https://img.shields.io/badge/Filament-v2.x-e9b228?style=for-the-badge"></a>
<a href="https://php.net"><img alt="PHP 8.0" src="https://img.shields.io/badge/PHP-8.0-777BB4?style=for-the-badge&logo=php"></a>
</p>

Help Desk is a Laravel based project, that let you manage your support tickets and communicate with your customers, with a beautiful and simple to use platform.

Help Desk is based on the latest version of Laravel and any other Open Source packages and technologies.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LogoutController extends Controller
public function __invoke(Request $request)
{
Auth::logout();
$request->session()->invalidate();
// $request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ class Kernel extends HttpKernel
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'can_access_ticket' => \App\Http\Middleware\CanAccessTicket::class,
'set_locale' => \App\Http\Middleware\LocaleMiddleware::class,
];
}
1 change: 1 addition & 0 deletions app/Http/Livewire/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function login(): void
]);
}

session()->put('locale', auth()->user()->locale);
redirect()->to(route('home'));

}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/MyNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function markAllRead(): void
Notification::make()
->success()
->title(__('Notifications updated'))
->body(__('All unread notifications is not marked as read'))
->body(__('All unread notifications is marked as read'))
->send();
}
}
14 changes: 13 additions & 1 deletion app/Http/Livewire/MyProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
Expand Down Expand Up @@ -42,7 +43,8 @@ private function initProfile(): void
$this->user = User::where('id', auth()->user()->id)->first();
$this->form->fill([
'name' => $this->user->name,
'email' => $this->user->email
'email' => $this->user->email,
'locale' => $this->user->locale,
]);
if (session()->has('profile_updated')) {
Notification::make()
Expand Down Expand Up @@ -86,6 +88,14 @@ protected function getFormSchema(): array
->label(__('Password confirmation'))
->dehydrated(false),
]),

Grid::make(1)
->schema([
Radio::make('locale')
->label(__('Default language'))
->options(locales())
->required()
]),
];
}

Expand All @@ -95,10 +105,12 @@ public function save(): void
if (Hash::check($data['current_password'], $this->user->password)) {
$this->user->name = $data['name'];
$this->user->email = $data['email'];
$this->user->locale = $data['locale'];
if ($data['new_password']) {
$this->user->password = bcrypt($data['new_password']);
}
$this->user->save();
session()->put('locale', $this->user->locale);
session()->flash('profile_updated', true);
redirect()->to(route('my-profile'));
} else {
Expand Down
28 changes: 28 additions & 0 deletions app/Http/Middleware/LocaleMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class LocaleMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$locale = config('app.locale');
if (session()->has('locale') && in_array(session()->get('locale'), array_keys(config('system.locales')))) {
$locale = session()->get('locale');
} else if (auth()->user()?->locale && in_array(auth()->user()?->locale, array_keys(config('system.locales')))) {
$locale = auth()->user()?->locale;
}
app()->setLocale($locale);
return $next($request);
}
}
1 change: 1 addition & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class User extends Authenticatable
'password',
'role',
'register_token',
'locale',
];

/**
Expand Down
16 changes: 16 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,19 @@ function types_list(): array
return $priorities;
}
}

if (!function_exists('locales')) {
/**
* Return application locales as an array of KEY (locale id) => VALUE (locale title)
*
* @return array
*/
function locales(): array
{
$roles = [];
foreach (config('system.locales') as $key => $value) {
$roles[$key] = __($value);
}
return $roles;
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"kkomelin/laravel-translatable-string-exporter": "^1.17",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
Expand Down
Loading