@@ -5,105 +5,4 @@ which can be easily turn on/off then this is a good package for you.
5
5
6
6
### How to Install my package?
7
7
8
- ` composer require "phpcodebooster/laravel" ` <br >
9
- ` php artisan vendor:publish `
10
-
11
- ### How to use this package?
12
-
13
- Let us create an Admin module that can be turned on/off from your
14
- laravel project
15
-
16
- - create a directory called Admin in "App/Modules" folder ex. app/Modules/Admin
17
- - open config/modules.php file and add following line:
18
-
19
- ``` php
20
- return [
21
- 'admin' => 'Admin Module'
22
- ];
23
- ```
24
-
25
- That is it your module is now enabled for your project. Following will be the ideal
26
- structure for your admin module
27
-
28
- ```
29
- project/
30
- app/
31
- └── Modules/
32
- └── Admin/
33
- ├── Controllers/
34
- │ └── AdminController.php
35
- ├── Models/
36
- │ └── User.php
37
- ├── Views/
38
- │ └── index.blade.php
39
- ├── Translations/
40
- │ └── en/
41
- │ └── example.php
42
- ├── routes.php
43
- └── config.php
44
- ```
45
-
46
- To access your module configuration use lowercase module name
47
- Ex.
48
-
49
- ``` php
50
- $admin_config = config('admin');
51
- ```
52
-
53
- To use admin views in your controller use:
54
-
55
- ``` php
56
- return view('admin::index');
57
- ```
58
-
59
- or
60
-
61
- ``` php
62
- return view('admin::folder.file');
63
- ```
64
-
65
- ### Sample Admin Module Code
66
-
67
- Create a folder called "Admin" in App/Modules
68
- Create directory called "Controllers" in App/Modules/Admin
69
- Create directory called "Views" in App/Modules/Admin
70
- Create a file called "routes.php" in App/Modules/Admin
71
- Create a file called "config.php" in App/Modules/Admin
72
-
73
- ### Create Sample Route, Controller and View file
74
-
75
- First, define a route in App/Modules/Admin/routes.php file as shown below:
76
-
77
- ``` php
78
- Route::get('/', 'HomeController@index')->name('home');
79
- ```
80
-
81
- Secondly, create a file called "HomeController.php" in App/Modules/Admin/Controllers with following contents
82
-
83
- ``` php
84
- <?php
85
-
86
- namespace App\Modules\Admin\Controllers;
87
- use App\Http\Controllers\Controller;
88
-
89
- class HomeController extends Controller
90
- {
91
- public function index()
92
- {
93
- dd( config('modules') );
94
- }
95
- }
96
- ```
97
-
98
- Now, once we have folder and file structure defined we have to enable admin module:
99
-
100
- open config/modules.php file and add following line:
101
-
102
-
103
- ``` php
104
- return [
105
- 'admin' => 'Admin Panel'
106
- ];
107
- ```
108
-
109
- Done, go to browser and hit your local website instance
8
+ Check out the docs at https://www.learn2torials.com/a/laravel-module-management
0 commit comments