Skip to content

Commit 13de88f

Browse files
Fixed issues
1 parent d9a4687 commit 13de88f

File tree

10 files changed

+134
-8
lines changed

10 files changed

+134
-8
lines changed

packages/Webkul/Admin/src/Resources/views/layouts/nav-top.blade.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,16 @@
142142
</div>
143143

144144
<div class="dropdown-list bottom-right">
145-
<span class="app-version">{{ __('admin::app.layouts.app-version', ['version' => 'v' . config('app.version')]) }}</span>
145+
<span class="app-version">
146+
<img
147+
src="{{ url('cache/logo.png') }}"
148+
width="24"
149+
style="margin-bottom: -5px;"
150+
/>
151+
152+
<!-- Version -->
153+
{{ __('admin::app.layouts.app-version', ['version' => 'v' . config('app.version')]) }}
154+
</span>
146155

147156
<div class="dropdown-container">
148157
<ul>

packages/Webkul/Installer/src/Database/Seeders/Attribute/AttributeSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function run($parameters = [])
2020

2121
$now = Carbon::now();
2222

23-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
23+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2424

2525
DB::table('attributes')->insert([
2626
[

packages/Webkul/Installer/src/Database/Seeders/EmailTemplate/EmailTemplateSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function run($parameters = [])
2020

2121
$now = Carbon::now();
2222

23-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
23+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2424

2525
DB::table('email_templates')->insert([
2626
[

packages/Webkul/Installer/src/Database/Seeders/Lead/PipelineSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function run($parameters = [])
2222

2323
$now = Carbon::now();
2424

25-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
25+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2626

2727
DB::table('lead_pipelines')->insert([
2828
[

packages/Webkul/Installer/src/Database/Seeders/Lead/SourceSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function run($parameters = [])
2020

2121
$now = Carbon::now();
2222

23-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
23+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2424

2525
DB::table('lead_sources')->insert([
2626
[

packages/Webkul/Installer/src/Database/Seeders/Lead/TypeSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function run($parameters = [])
2020

2121
$now = Carbon::now();
2222

23-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
23+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2424

2525
DB::table('lead_types')->insert([
2626
[

packages/Webkul/Installer/src/Database/Seeders/User/RoleSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function run($parameters = [])
1919

2020
DB::table('roles')->delete();
2121

22-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
22+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2323

2424
DB::table('roles')->insert([
2525
'id' => 1,

packages/Webkul/Installer/src/Database/Seeders/Workflow/WorkflowSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function run($parameters = [])
2020

2121
$now = Carbon::now();
2222

23-
$defaultLocale = $parameters['default_locale'] ?? config('app.locale');
23+
$defaultLocale = $parameters['locale'] ?? config('app.locale');
2424

2525
DB::table('workflows')->insert([
2626
[
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
namespace Webkul\Installer\Http\Controllers;
4+
5+
use Illuminate\Http\Response as IlluminateResponse;
6+
use Illuminate\Support\Facades\Cache;
7+
8+
class ImageCacheController
9+
{
10+
/**
11+
* Cache template
12+
*
13+
* @var string
14+
*/
15+
protected $template;
16+
17+
/**
18+
* Logo
19+
*
20+
* @var string
21+
*/
22+
const KRAYIN_LOGO = 'https://updates.krayincrm.com/krayin.png';
23+
24+
/**
25+
* Get HTTP response of template applied image file
26+
*
27+
* @param string $filename
28+
* @return Illuminate\Http\Response
29+
*/
30+
public function getImage($filename)
31+
{
32+
try {
33+
$content = Cache::remember('krayin-logo', 10080, function () {
34+
return $this->getImageFromUrl(self::KRAYIN_LOGO);
35+
});
36+
} catch (\Exception $e) {
37+
$content = '';
38+
}
39+
40+
return $this->buildResponse($content);
41+
}
42+
43+
/**
44+
* Init from given URL
45+
*
46+
* @param string $url
47+
* @return \Intervention\Image\Image
48+
*/
49+
public function getImageFromUrl($url)
50+
{
51+
$domain = config('app.url');
52+
53+
$options = [
54+
'http' => [
55+
'method' => 'GET',
56+
'protocol_version' => 1.1, // force use HTTP 1.1 for service mesh environment with envoy
57+
'header' => "Accept-language: en\r\n".
58+
"Domain: $domain\r\n".
59+
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n",
60+
],
61+
];
62+
63+
$context = stream_context_create($options);
64+
65+
if ($data = @file_get_contents($url, false, $context)) {
66+
return $data;
67+
}
68+
69+
throw new \Exception(
70+
'Unable to init from given url ('.$url.').'
71+
);
72+
}
73+
74+
/**
75+
* Builds HTTP response from given image data
76+
*
77+
* @param string $content
78+
* @return Illuminate\Http\Response
79+
*/
80+
protected function buildResponse($content)
81+
{
82+
/**
83+
* Define mime type
84+
*/
85+
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
86+
87+
/**
88+
* Respond with 304 not modified if browser has the image cached
89+
*/
90+
$eTag = md5($content);
91+
92+
$notModified = isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $eTag;
93+
94+
$content = $notModified ? null : $content;
95+
96+
$statusCode = $notModified ? 304 : 200;
97+
98+
/**
99+
* Return http response
100+
*/
101+
return new IlluminateResponse($content, $statusCode, [
102+
'Content-Type' => $mime,
103+
'Cache-Control' => 'max-age=10080, public',
104+
'Content-Length' => strlen($content),
105+
'Etag' => $eTag,
106+
]);
107+
}
108+
}

packages/Webkul/Installer/src/Providers/InstallerServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ public function boot()
2525
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'installer');
2626

2727
Event::listen('bagisto.installed', 'Webkul\Installer\Listeners\Installer@installed');
28+
29+
30+
/**
31+
* Route to access template applied image file
32+
*/
33+
$this->app['router']->get('cache/{filename}', [
34+
'uses' => 'Webkul\Installer\Http\Controllers\ImageCacheController@getImage',
35+
'as' => 'image_cache',
36+
])->where(['filename' => '[ \w\\.\\/\\-\\@\(\)\=]+']);
2837
}
2938

3039
/**

0 commit comments

Comments
 (0)