Skip to content
Open
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
APP_ENV=local
APP_DEBUG=true
APP_DIRECTION=rtl
APP_KEY=i53weLzCSdunQzNc2SXR2AE9XJVDuNaq

DB_HOST=localhost
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ClientsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function index()
public function anyData()
{
$clients = Client::select(['external_id', 'company_name', 'vat', 'address']);
$confirmMessage = 'Are you sure? All the clients tasks, leads, projects, etc will be deleted as well';
return Datatables::of($clients)
->addColumn('namelink', '<a href="{{ route("clients.show",[$external_id]) }}">{{$company_name}}</a>')
->addColumn('view', '
Expand All @@ -72,7 +73,7 @@ public function anyData()
->addColumn('delete', '
<form action="{{ route(\'clients.destroy\', $external_id) }}" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="submit" name="submit" value="' . __('Delete') . '" class="btn btn-link" onClick="return confirm(\'Are you sure? All the clients tasks, leads, projects, etc will be deleted as well\')"">
<input type="submit" name="submit" value="' . __('Delete') . '" class="btn btn-link" onClick="return confirm(\''.__($confirmMessage).'\')"">
{{csrf_field()}}
</form>')
->rawColumns(['namelink', 'view','edit', 'delete'])
Expand Down
6 changes: 5 additions & 1 deletion app/Http/Middleware/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Config;

class Translation
{
Expand All @@ -17,10 +18,13 @@ public function handle($request, Closure $next)
{
if (auth()->user()) {
$language = auth()->user()->language;
if (!in_array($language, ["en", "dk", "es"])) {
if (!in_array($language, ["en", "dk", "es", "fa"])) {
$language = "en";
}
app()->setLocale($language);
if ($language === "fa") {
Config::set('app.direction', 'rtl');
}
}
return $next($request);
}
Expand Down
22 changes: 22 additions & 0 deletions app/Http/ViewComposers/DataTableLanguageComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace App\Http\ViewComposers;

use Illuminate\View\View;
use App\Models\User;

class DataTableLanguageComposer
{

/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$dataTableLanguageFile = asset('lang/' . (in_array(\Lang::locale(), ['dk', 'en', 'fa']) ? \Lang::locale() : 'en') . '/datatable.json');

$view->with('dataTableLanguageFile', $dataTableLanguageFile);
}
}
20 changes: 20 additions & 0 deletions app/Providers/ViewComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ public function boot()
['invoices.show'],
'App\Http\ViewComposers\InvoiceHeaderComposer'
);

view()->composer(
[
'departments.index',
'absence.index',
'clients.index',
'clients.tabs.invoicetab',
'clients.tabs.leadtab',
'clients.tabs.projectstab',
'clients.tabs.tasktab',
'datatables.index',
'invoices._paymentList',
'projects.index',
'roles.index',
'tasks.index',
'users.index',
'users.show'
],
'App\Http\ViewComposers\DataTableLanguageComposer'
);
}

/**
Expand Down
7 changes: 7 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,11 @@
'ability' => App\Zizaco\Entrust\Middleware\EntrustAbility::class,
],

/*
|--------------------------------------------------------------------------
| Application Direction
|--------------------------------------------------------------------------
*/

'direction' => env('APP_DIRECTION', 'ltr'),
];
Loading