Skip to content

Commit

Permalink
minor bug fix and few improvement in asset manager
Browse files Browse the repository at this point in the history
  • Loading branch information
indpurvesh committed Oct 19, 2020
1 parent a1d2049 commit f961241
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/AssetsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getCSS($key)
$index = $this->styles->search(function($item) use ($key) {
return $item->key() === $key;
});
return $this->styles->get($key);
return $this->styles->get($index);
}

/**
Expand Down Expand Up @@ -79,6 +79,7 @@ public function registerCSS($item)
*/
public function renderJS(): View
{
// dd($this->scripts);
return view('avored-assets::js.index')
->with('scripts', $this->scripts);
}
Expand Down
14 changes: 12 additions & 2 deletions src/Controllers/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ class AssetController
{
public function adminJS(string $key)
{
$file = Asset::getJS($key);
$asset = Asset::getJS($key);
$file = $asset->path();

if ($file === null && !file_exists($file)) {
throw new \Exception('JS File not found: ' . $file);
}

$expires = strtotime('+1 year');
$lastModified = filemtime($file);
Expand All @@ -24,8 +29,13 @@ public function adminJS(string $key)

public function adminCSS($key)
{
$file = Asset::getCSS($key);
$asset = Asset::getJS($key);
$file = $asset->path();

if ($file === null && !file_exists($file)) {
throw new \Exception('CSS File not found: ' . $file);
}

$expires = strtotime('+1 year');
$lastModified = filemtime($file);
$cacheControl = 'public, max-age=31536000';
Expand Down

0 comments on commit f961241

Please sign in to comment.