Skip to content

Commit 1861ae5

Browse files
committed
version 1.0
1 parent 5e0f328 commit 1861ae5

25 files changed

+3727
-186
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DB_CONNECTION=
2+
DB_HOST=
3+
DB_PORT=
4+
DB_DATABASE=
5+
DB_USERNAME=
6+
DB_PASSWORD=
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace App\Exceptions\Container;
4+
5+
use PHPMini\Container\Exceptions\ContainerExceptionInterface;
6+
7+
class ContainerException extends \Exception implements ContainerExceptionInterface
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace App\Exceptions\Container;
4+
5+
use PHPMini\Container\Exceptions\NotFoundExceptionInterface;
6+
7+
class NotFoundException extends \Exception implements NotFoundExceptionInterface
8+
{
9+
}

app/Http/Controllers/Controller.php

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,15 @@ public function __construct()
1414
if (session_status() === PHP_SESSION_NONE) {
1515
session_start();
1616
}
17-
$this->db = new DBConnection(DB, DB_NAME, DB_HOST, DB_USER, DB_PWD);
17+
$this->db = new DBConnection(
18+
env("DB_CONNECTION", "mysql"),
19+
env("DB_DATABASE"),
20+
env("DB_HOST"),
21+
env("DB_USERNAME"),
22+
env("DB_PASSWORD")
23+
);
1824
}
19-
// render a view
20-
protected function view(string $path, array $context = [], ?string $layout = null)
21-
{
22-
if (!empty($context)) {
23-
foreach ($context as $k => $value) {
24-
$$k = $value;
25-
}
26-
}
27-
28-
if (is_null($layout)) {
29-
$path = str_replace('.', DIRECTORY_SEPARATOR, $path);
30-
require VIEWS . $path . '.php';
31-
} else {
32-
ob_start();
33-
$path = str_replace('.', DIRECTORY_SEPARATOR, $path);
34-
require VIEWS . $path . '.php';
35-
$content = ob_get_clean();
36-
$layout_path = str_replace('.', DIRECTORY_SEPARATOR, $layout);
37-
require VIEWS . $layout_path . '.php';
38-
}
39-
}
40-
25+
4126
protected function getDB(): DBConnection
4227
{
4328
return $this->db;

app/Http/Controllers/HomeController.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\User;
6-
use App\Requests\Request;
6+
use App\Http\Requests\Request;
77

88
class HomeController extends Controller
99
{
1010
public function error404()
1111
{
12-
return $this->view('errors/error404');
12+
return view('errors.error404');
1313
}
14-
public function welcome()
14+
public function welcome(User $user)
1515
{
16-
$user = User::where([
17-
'username' => "Tores",
18-
])->firstOr(function () {
19-
return User::find(1);
20-
});
21-
var_dump($user) or die;
22-
return $this->view('welcome');
16+
$users = User::where('id', '>=', 8)
17+
->orWhere('id', 1)
18+
->limit(5)
19+
->get();
20+
dd($user);
21+
return view('welcome', compact('user'));
2322
}
2423
}

0 commit comments

Comments
 (0)