-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
249 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace App\Controllers\Web; | ||
|
||
use App\Models\Category; | ||
use App\Models\Product; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Slim\App; | ||
use Slim\Psr7\Factory\ServerRequestFactory; | ||
use Vesp\Controllers\Controller; | ||
use Vesp\Services\Eloquent; | ||
|
||
class Resource extends Controller | ||
{ | ||
private App $app; | ||
|
||
public function __construct(App $app, Eloquent $eloquent) | ||
{ | ||
parent::__construct($eloquent); | ||
$this->app = $app; | ||
} | ||
|
||
public function get(): ResponseInterface | ||
{ | ||
$uri = trim($this->getProperty('uri', ''), '/'); | ||
$endpoint = trim($this->request->getRequestTarget(), '/'); | ||
$factory = new ServerRequestFactory(); | ||
|
||
if (Product::query()->where('uri', $uri)->count()) { | ||
$endpoint = str_replace('/resource/', '/products/', $endpoint); | ||
$request = $factory->createServerRequest('GET', $endpoint); | ||
} elseif (Category::query()->where('uri', $uri)->count()) { | ||
$endpoint = str_replace('/resource/', '/categories/', $endpoint); | ||
$request = $factory->createServerRequest('GET', $endpoint); | ||
} else { | ||
return $this->failure('Not Found', 404); | ||
} | ||
|
||
foreach ($this->request->getHeaders() as $key => $value) { | ||
$request = $request->withHeader($key, $value); | ||
} | ||
|
||
return $this->app->handle($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.toasted-container { | ||
.toasted { | ||
padding: 0.75rem 1.25rem; | ||
border-radius: $border-radius; | ||
color: $white; | ||
|
||
&.success { | ||
background-color: rgba($success, 0.9); | ||
} | ||
|
||
&.info { | ||
background-color: rgba($info, 0.9); | ||
} | ||
|
||
&.error { | ||
background-color: rgba($danger, 0.9); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.