Skip to content

Commit 49aab14

Browse files
committed
feat: add specialized MVC pages
1 parent 87592f6 commit 49aab14

File tree

5 files changed

+112
-4
lines changed

5 files changed

+112
-4
lines changed

.vitepress/config/sidebar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const sidebar = [
2929
{ text: 'Route Groups', link: '/docs/routing/route-groups' },
3030
{ text: 'Dynamic routing', link: '/docs/routing/dynamic' },
3131
{ text: 'Middleware', link: '/docs/routing/middleware/' },
32-
{ text: 'Middleware in Leaf MVC', link: '/docs/routing/middleware/mvc' },
32+
// { text: 'Middleware in Leaf MVC', link: '/docs/routing/middleware/mvc' },
3333
],
3434
},
3535
{

src/docs/database/index.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- markdownlint-disable no-inline-html -->
44

55
<script setup>
6-
import VideoModal from '@theme/components/shared/VideoModal.vue'
6+
import VideoModal from '@theme/components/shared/VideoModal.vue';
7+
import Button from '@theme/components/shared/Button.vue';
78
</script>
89

910
A database is an organized storage system for managing data like your users' profiles or product details. Leaf offers a lightweight module that simplifies database interaction and supports five major database systems.
@@ -51,7 +52,37 @@ Databases are essential for most applications, as they help you store and retrie
5152

5253
## Leaf MVC + DB
5354

54-
Leaf MVC comes with built-in support for models which are a way to programmatically represent resources in your database using PHP classes. For that reason, you have no real need to use the `db()` function unless you want to quickly run a query without creating a model. Still, everything has been set up for you and Leaf DB will use the default database connection details in your `.env` file.
55+
<div
56+
class="w-full relative text-white overflow-hidden rounded-3xl flex shadow-lg sm:max-w-[50%]"
57+
>
58+
<div
59+
class="w-full flex md:flex-col bg-gradient-to-br from-pink-500 to-rose-500"
60+
>
61+
<div
62+
class="sm:flex-none md:w-auto md:flex-auto flex flex-col items-start relative z-10 p-6"
63+
>
64+
<p class="font-medium text-rose-100 text-shadow mb-4">
65+
Models are a more powerful way to interact with your database in Leaf MVC using an object-oriented approach, which also makes your code more readable and maintainable.
66+
</p>
67+
<Button
68+
as="a"
69+
href="/docs/database/models"
70+
class="mt-auto bg-rose-900 hover:!bg-rose-900 !text-white bg-opacity-50 hover:bg-opacity-75 transition-colors duration-200 rounded-xl font-bold py-2 px-4 inline-flex"
71+
>Let's go</Button
72+
>
73+
</div>
74+
<!-- <div
75+
class="relative md:pl-6 xl:pl-8 hidden sm:block"
76+
>
77+
Hello
78+
</div> -->
79+
</div>
80+
<div
81+
class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-rose-500 hidden sm:block"
82+
></div>
83+
</div>
84+
85+
If you still want to use Leaf DB with Leaf MVC, everything has been set up for you and Leaf DB will use the default database connection details in your `.env` file.
5586

5687
Here are a few example connections:
5788

src/docs/routing/index.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- markdownlint-disable no-inline-html -->
44

55
<script setup>
6-
import VideoModal from '@theme/components/shared/VideoModal.vue'
6+
import VideoModal from '@theme/components/shared/VideoModal.vue';
7+
import Button from '@theme/components/shared/Button.vue';
78
</script>
89

910
Routing is the foundation of every web application. It's the process of defining the URL structure of your application and how it responds to requests. Leaf comes with a powerful router that simplifies the way you define routes in your application. You can take routing as one fancy traffic officer that directs traffic to the right place.
@@ -16,6 +17,39 @@ Routing is the foundation of every web application. It's the process of defining
1617

1718
## Create a route
1819

20+
<div
21+
class="w-full relative text-white overflow-hidden rounded-3xl flex shadow-lg sm:max-w-[50%]"
22+
>
23+
<div
24+
class="w-full flex md:flex-col bg-gradient-to-br from-pink-500 to-rose-500"
25+
>
26+
<div
27+
class="sm:flex-none md:w-auto md:flex-auto flex flex-col items-start relative z-10 p-6"
28+
>
29+
<h3 class="text-xl font-semibold mb-2 text-shadow !mt-0">
30+
Using Leaf MVC?
31+
</h3>
32+
<p class="font-medium text-rose-100 text-shadow mb-4">
33+
We've crafted a specialized guide for routing in Leaf MVC. While it's similar to the basic routing in Leaf, it's more detailed and tailored for Leaf MVC.
34+
</p>
35+
<Button
36+
as="a"
37+
href="/docs/routing/mvc"
38+
class="mt-auto bg-rose-900 hover:!bg-rose-900 !text-white bg-opacity-50 hover:bg-opacity-75 transition-colors duration-200 rounded-xl font-bold py-2 px-4 inline-flex"
39+
>Start building</Button
40+
>
41+
</div>
42+
<!-- <div
43+
class="relative md:pl-6 xl:pl-8 hidden sm:block"
44+
>
45+
Hello
46+
</div> -->
47+
</div>
48+
<div
49+
class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-rose-500 hidden sm:block"
50+
></div>
51+
</div>
52+
1953
Every route has a URL (the web address the user visits) and an HTTP method (like GET, POST, etc.), which tells the server what action to take. For example, if you create a route for a GET request to `/home`, the user can access that page by visiting `http://example.com/home`. This way, different URLs and methods control how users interact with your app.
2054

2155
So to define a route, you need to specify the URL and the HTTP method. Leaf router allows you to do this using `get()`, `post()`, `put()`, `patch()`, `delete()`, ... methods. Let's take a look at them.

src/docs/routing/middleware/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
11
# Middleware
22

3+
<!-- markdownlint-disable no-inline-html -->
4+
5+
<script setup>
6+
import VideoModal from '@theme/components/shared/VideoModal.vue';
7+
import Button from '@theme/components/shared/Button.vue';
8+
</script>
9+
310
Middleware is a piece of code that runs before or after your application processes a request. It helps control the flow of requests and responses. For example, when a user visits a page on your app, you can use middleware can check if the user is logged in and if everything is okay, the request moves on to the next step; if not, the middleware can redirect the user.
411

512
Middleware can be used for a variety of tasks, such as authentication, authorization, logging, error handling, session management, and more.
613

14+
<div
15+
class="w-full relative text-white overflow-hidden rounded-3xl flex shadow-lg sm:max-w-[50%]"
16+
>
17+
<div
18+
class="w-full flex md:flex-col bg-gradient-to-br from-pink-500 to-rose-500"
19+
>
20+
<div
21+
class="sm:flex-none md:w-auto md:flex-auto flex flex-col items-start relative z-10 p-6"
22+
>
23+
<h3 class="text-xl font-semibold mb-2 text-shadow !mt-0">
24+
Using Leaf MVC?
25+
</h3>
26+
<p class="font-medium text-rose-100 text-shadow mb-4">
27+
We've crafted a specialized guide for routing in Leaf MVC. While it's similar to the base middleware in Leaf, it's more detailed and tailored for Leaf MVC.
28+
</p>
29+
<Button
30+
as="a"
31+
href="/docs/routing/middleware/mvc"
32+
class="mt-auto bg-rose-900 hover:!bg-rose-900 !text-white bg-opacity-50 hover:bg-opacity-75 transition-colors duration-200 rounded-xl font-bold py-2 px-4 inline-flex"
33+
>Start building</Button
34+
>
35+
</div>
36+
<!-- <div
37+
class="relative md:pl-6 xl:pl-8 hidden sm:block"
38+
>
39+
Hello
40+
</div> -->
41+
</div>
42+
<div
43+
class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-rose-500 hidden sm:block"
44+
></div>
45+
</div>
46+
747
## Middleware in Leaf
848

949
Leaf is a modular framework, so we don't throw everything into the core. However, some common middleware are built into respective modules like the Auth module which has middleware for authentication, the CORS module, and the CSRF module which come with their own implementation.

src/docs/routing/mvc.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Routing in Leaf MVC
2+
3+

0 commit comments

Comments
 (0)