Skip to content

Commit 3f832d3

Browse files
committed
💡 updated examples
1 parent 742973c commit 3f832d3

File tree

8 files changed

+50
-75
lines changed

8 files changed

+50
-75
lines changed

App/Database/Schema/users.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"id": 1,
33
"username?": "mychi.darko",
4-
"fullname": "Mychi Darko",
4+
"name": "Mychi Darko",
55
"email?": "[email protected]",
6-
"phone": "233504766732",
76
"email_verified_at?": "2021-07-23T16:18:35.947712157Z",
87
"password": "poekojdenwjwiojweojojweoijoewoj",
98
"remember_token?": "deiwoj",

App/Helpers/.init

Whitespace-only changes.

App/Helpers/UsersHelper.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use App\Models\User;
4+
5+
/**
6+
* Helpers basically contain static functions
7+
* which take care of some specific functionality.
8+
*/
9+
class UsersHelper
10+
{
11+
public static function notify($user, $message)
12+
{
13+
$user = User::find($user);
14+
15+
// make sure user exists
16+
response()->throwErr("User not found", 404);
17+
18+
// create the notification record
19+
// $notification = new Notification();
20+
// $notification->user_id = $user;
21+
// $notification->message = $message;
22+
// $notification->save();
23+
}
24+
}

App/Routes/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
| Create a handler for error 500
2323
|
2424
*/
25-
// $app->setErrorHandler(function() {
26-
// response()->page(ViewsPath("errors/500.html", false), 500);
27-
// });
25+
$app->setErrorHandler(function() {
26+
response()->page(ViewsPath("errors/500.html", false), 500);
27+
});
2828

2929
/*
3030
|--------------------------------------------------------------------------

App/Views/assets/css/styles.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ body {
66
align-items: center;
77
font: 12px/1.5 Helvetica, Arial, Verdana, sans-serif;
88
flex-direction: column;
9-
background: linear-gradient(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.4)), url(./../img/bg.png);
9+
background: linear-gradient(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.4)), url(./../img/bg.png) no-repeat;
10+
background-size: cover;
11+
background-position: center 200px;
12+
width: 100vw;
1013
}
1114

1215
h1 {
@@ -56,4 +59,4 @@ ul {
5659

5760
section:not(:last-child) {
5861
margin-bottom: 30px;
59-
}
62+
}

App/Views/index.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>{{ getenv('APP_NAME') ?? "Leaf MVC" }}</title>
7+
<title>{{ _env("APP_NAME", "Leaf MVC") }}</title>
88
<link rel="shortcut icon" href="https://leafphp.netlify.app/img/logo.png" type="image/x-icon">
99
<link rel="stylesheet" href="{{ ViewsPath("assets/css/styles.css") }}">
1010
<script src="https://unpkg.com/petite-vue" defer init></script>
@@ -13,7 +13,7 @@
1313
<body>
1414
<div id="app" style="margin-top: 35px;">
1515
<section>
16-
<h1>{{ getenv('APP_NAME') ?? "Leaf MVC" }}</h1>
16+
<h1>{{ _env("APP_NAME", "Leaf MVC") }}</h1>
1717
<p>
1818
This is the LeafMVC framework. A simple MVC framework built for
1919
<a href="https://leafphp.dev" class="text-green">Leaf PHP Framework</a>
@@ -33,7 +33,7 @@
3333
</section>
3434
<section v-scope="{ show: 0 }">
3535
<button @click="show = !show">Learn Leaf MVC</button>
36-
<div class="collection" v-if="show">
36+
<div class="collection" v-if="show" style="margin-top: 10px;">
3737
<a href="https://leafphp.netlify.app/#/leaf-mvc/" target="_blank" class="collection-item">
3838
Read our informative docs
3939
</a>

Config/functions.php

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ function auth($guard = null)
5555
}
5656
}
5757

58-
if (!function_exists('d')) {
59-
/**
60-
* Return Leaf's date object
61-
*/
62-
function d()
63-
{
64-
return app()->date;
65-
}
66-
}
67-
6858
if (!function_exists('dbRow')) {
6959
/**
7060
* Return a db row by it's id
@@ -105,16 +95,6 @@ function email(array $email)
10595
}
10696
}
10797

108-
if (!function_exists('fs')) {
109-
/**
110-
* Return Leaf's FS object
111-
*/
112-
function fs()
113-
{
114-
return app()->fs;
115-
}
116-
}
117-
11898
if (!function_exists('flash')) {
11999
/**
120100
* Return Leaf's flash object
@@ -213,34 +193,3 @@ function setHeader($key, $value = "", $replace = true, $code = 200)
213193
app()->headers()->set($key, $value, $replace, $code);
214194
}
215195
}
216-
217-
if (!function_exists("view")) {
218-
function view(string $view, array $data = [])
219-
{
220-
if (ViewConfig("render")) {
221-
ViewConfig("config")([
222-
"views_path" => AppConfig("views.path"),
223-
"cache_path" => AppConfig("views.cachePath"),
224-
]);
225-
226-
return ViewConfig("render")($view, $data);
227-
}
228-
229-
$engine = ViewConfig("view_engine");
230-
231-
$className = strtolower(get_class(new $engine));
232-
233-
$fullName = explode("\\", $className);
234-
$className = $fullName[count($fullName) - 1];
235-
236-
if (forward_static_call_array(["Leaf\\View", $className], [])) {
237-
forward_static_call_array(["Leaf\\View", $className], [])->configure(AppConfig("views.path"), AppConfig("views.cachePath"));
238-
return forward_static_call_array(["Leaf\\View", $className], [])->render($view, $data);
239-
}
240-
241-
$engine = new $engine($engine);
242-
$engine->config(AppConfig("views.path"), AppConfig("views.cachePath"));
243-
244-
return $engine->render($view, $data);
245-
}
246-
}

index.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
*/
1313
require __DIR__ . '/vendor/autoload.php';
1414

15+
/*
16+
|--------------------------------------------------------------------------
17+
| Bring in (env)
18+
|--------------------------------------------------------------------------
19+
|
20+
| Quickly use our environment variables
21+
|
22+
*/
23+
try {
24+
\Dotenv\Dotenv::create(__DIR__)->load();
25+
} catch (\Throwable $th) {
26+
trigger_error($th);
27+
}
28+
1529
/*
1630
|--------------------------------------------------------------------------
1731
| Shortcut functions
@@ -54,20 +68,6 @@
5468
*/
5569
Leaf\Core::paths(PathsConfig());
5670

57-
/*
58-
|--------------------------------------------------------------------------
59-
| Bring in (env)
60-
|--------------------------------------------------------------------------
61-
|
62-
| Quickly use our environment variables
63-
|
64-
*/
65-
try {
66-
\Dotenv\Dotenv::create(__DIR__)->load();
67-
} catch (\Throwable $th) {
68-
trigger_error($th);
69-
}
70-
7171
/*
7272
|--------------------------------------------------------------------------
7373
| Default fix for CORS

0 commit comments

Comments
 (0)