Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 0095fec

Browse files
committed
cleanups
1 parent 0f512e5 commit 0095fec

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,22 @@ return [
7777
### Good Practice
7878
Ofcourse you are free to code your app the way you want, but just in-case here are the naming convention the package use.
7979

80-
- `title` > `title_case(some title)`
81-
- `route_name` > `str_slug(title)`
82-
- `action` > `SomeController\camelCase(title)`
80+
| column name | format | output |
81+
|-------------|--------------------------------------|------------|
82+
| title | title_case(some title) | Some Title |
83+
| route_name | str_slug(Some Title) | some-title |
84+
| action | SomeController\camelCase(Some Title) | someTitle |
8385

8486
## Notes
85-
- for the pages with "action" you can get all the page params like **template, title, body, desc, breadCrump** inside your "action@method" by using `extract(cache('the_route_name'));`
87+
- you can get any page params like (**template, title, body, desc, breadCrump**) by using `extract(cache('the_route_name'));`
8688

8789
<u>**or**</u>
88-
- if you followed the naming convention above, you can instead use `extract(cache(kebab_case('TheCurrentMethodName')));`
90+
91+
- if you followed the naming convention above and you are inside the `page action method`, you can instead use `extract(cache(kebab_case('TheCurrentMethodName')));`
92+
93+
| method name | format | output = route_name |
94+
|-------------|-------------------------|---------------------|
95+
| contactUs | kebab_case('contactUs') | contact-us |
8996

9097
# ToDo
9198

src/Controller/DummyController.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ public function handle()
1111
{
1212
extract(cache(Route::currentRouteName()));
1313

14-
return view(config('simpleMenu.templatePath').".$template")->with([
15-
'title' => $title,
16-
'body' => $body,
17-
'desc' => $desc,
18-
'breadCrump' => $breadCrump,
19-
]);
14+
return view(config('simpleMenu.templatePath').".$template", compact('title', 'body', 'desc', 'breadCrump'));
2015
}
2116
}

src/Traits/RoutesTrait.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,20 @@ protected function routeGen($routeName, $url, $prefix, $action, $roles, $permiss
9191
return;
9292
}
9393

94+
// cache the page so we pass the page params to the controller@method
95+
Cache::forever($routeName, compact('template', 'title', 'body', 'desc', 'breadCrump'));
96+
9497
$route = $this->getRouteUrl($url, $prefix);
9598

9699
// dynamic
97100
if ($action) {
98-
Cache::forever($routeName, compact('template', 'title', 'body', 'desc', 'breadCrump'));
99-
100101
Route::get($route)
101102
->uses(config('simpleMenu.pagesControllerNS').'\\'.$action)
102103
->name($routeName)
103104
->middleware([$roles, $permissions]);
104105
}
105106
// static
106107
else {
107-
Cache::forever($routeName, compact('template', 'title', 'body', 'desc', 'breadCrump'));
108-
109108
Route::get($route)
110109
->uses('\ctf0\SimpleMenu\Controller\DummyController@handle')
111110
->name($routeName)

src/database/seeds/PagesTableSeeder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function run()
2020
'template' => 'hero',
2121
'action' => 'PageController@'.camel_case($one),
2222
'title' => [
23-
'en' => $one,
24-
'fr' => $one,
23+
'en' => title_case($one),
24+
'fr' => title_case($one),
2525
],
2626
'body' => [
2727
'en' => $faker->text(),
@@ -44,11 +44,11 @@ public function run()
4444
$fr = $faker->unique()->city;
4545

4646
Page::create([
47-
'template' => 'hero',
4847
'route_name'=> str_slug($en),
48+
'template' => 'hero',
4949
'title' => [
50-
'en' => $en,
51-
'fr' => $fr,
50+
'en' => title_case($en),
51+
'fr' => title_case($fr),
5252
],
5353
'body' => [
5454
'en' => $faker->text(),

0 commit comments

Comments
 (0)