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

Commit 405b56f

Browse files
committed
add support for page icon
1 parent 2dc7461 commit 405b56f

File tree

9 files changed

+106
-72
lines changed

9 files changed

+106
-72
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# SimpleMenu
22

3-
[![Latest Stable Version](https://img.shields.io/packagist/v/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu) [![Total Downloads](https://img.shields.io/packagist/dt/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu)
4-
[![Donate with Bitcoin](https://en.cryptobadges.io/badge/micro/16ri7Hh848bw7vxbEevKHFuHXLmsV8Vc9L)](https://en.cryptobadges.io/donate/16ri7Hh848bw7vxbEevKHFuHXLmsV8Vc9L)
3+
[![Latest Stable Version](https://img.shields.io/packagist/v/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu) [![Total Downloads](https://img.shields.io/packagist/dt/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu) [![Donate with Bitcoin](https://en.cryptobadges.io/badge/micro/16ri7Hh848bw7vxbEevKHFuHXLmsV8Vc9L)](https://en.cryptobadges.io/donate/16ri7Hh848bw7vxbEevKHFuHXLmsV8Vc9L)
54

65
Create menus & pages that support (multiLocale "title, url, body, ...", nesting, template, static & dynamic data, roles & permissions).
76

87
- package requires Laravel v5.5+
9-
- package rely heavily on caching through **Redis**, so make sure to check the [docs](https://laravel.com/docs/5.5/redis) for installation & configuration.
8+
- package rely heavily on caching so make sure to install one of the tag enabled drivers [Memcached / Redis](https://laravel.com/docs/5.5/cache)
109

1110
<br>
1211

@@ -171,4 +170,4 @@ return [
171170
<br>
172171
173172
## Crud Views
174-
[Wiki](https://github.com/ctf0/SimpleMenu/wiki/Crud-Views)
173+
[Wiki](https://github.com/ctf0/SimpleMenu/wiki/Crud-Views)

src/SimpleMenuServiceProvider.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace ctf0\SimpleMenu;
44

5-
use Illuminate\Support\Facades\URL;
65
use Illuminate\Support\ServiceProvider;
76
use ctf0\SimpleMenu\Observers\MenuObserver;
87
use ctf0\SimpleMenu\Observers\PageObserver;
@@ -79,7 +78,7 @@ protected function observers()
7978
{
8079
$config = config('simpleMenu.models');
8180

82-
if (!app()->runningInConsole() && $config) {
81+
if ($config) {
8382
app(array_get($config, 'page'))->observe(PageObserver::class);
8483
app(array_get($config, 'menu'))->observe(MenuObserver::class);
8584
app(array_get($config, 'user'))->observe(UserObserver::class);
@@ -94,15 +93,15 @@ protected function observers()
9493
protected function macros()
9594
{
9695
// alias to "Route::is()" but with support for params
97-
URL::macro('is', function ($route_name, $params = null) {
96+
app('url')->macro('is', function ($route_name, $params = null) {
9897
if ($params) {
9998
return request()->url() == route($route_name, $params);
10099
}
101100

102101
return request()->url() == route($route_name);
103102
});
104103

105-
URL::macro('has', function ($needle) {
104+
app('url')->macro('has', function ($needle) {
106105
return str_contains($this->current(), $needle);
107106
});
108107
}
@@ -121,7 +120,7 @@ protected function viewComp()
121120
});
122121
}
123122

124-
/**
123+
/**
125124
* [autoReg description].
126125
*
127126
* @return [type] [description]

src/database/migrations/2017_02_28_202951_create_pages_table.php

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function up()
2020

2121
$table->string('cover')->nullable();
2222
$table->string('action')->nullable();
23+
$table->string('icon')->nullable();
2324
$table->string('template')->nullable();
2425
$table->string('middlewares')->nullable();
2526
$table->string('route_name')->nullable();

src/database/seeds/DatabaseSeeder.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class DatabaseSeeder extends Seeder
99
*/
1010
public function run()
1111
{
12-
Cache::flush();
12+
app('cache')->flush();
13+
app('files')->delete(config('simpleMenu.routeListPath'));
1314

1415
$this->call(PagesTableSeeder::class);
1516
$this->call(MenusTableSeeder::class);

src/resources/assets/js/menu.vue

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<style scoped lang="scss">
2+
.menu-list {
3+
a:hover {
4+
color: unset !important;
5+
background-color: unset !important;
6+
}
7+
}
8+
</style>
9+
110
<script>
211
import draggable from 'vuedraggable'
312
import MenuChild from './menu_child.vue'
@@ -15,14 +24,14 @@ export default {
1524
saveList: []
1625
}
1726
},
27+
created() {
28+
this.getPages()
29+
},
1830
computed: {
1931
finalList() {
2032
return JSON.stringify(this.saveList)
2133
}
2234
},
23-
created() {
24-
this.getPages()
25-
},
2635
methods: {
2736
getPages() {
2837
axios.get(this.getMenuPages)

src/resources/assets/sass/style.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ thead th {
8787
.toggle-locale {
8888
position: absolute;
8989
z-index: 1;
90-
top: 0;
91-
right: 0;
90+
top: 1px;
91+
right: 1px;
9292
opacity: 0.3;
9393

9494
&:hover {

src/resources/lang/en/messages.php

+56-55
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,59 @@
11
<?php
22

3-
return array (
4-
'access' => 'Access',
5-
'account' => 'Account',
6-
'action' => 'Action',
7-
'add_new' => 'Add new',
8-
'avatar' => 'Avatar',
9-
'background' => 'Background',
10-
'bio' => 'Bio',
11-
'body' => 'Body',
12-
'content' => 'Content',
13-
'control' => 'Control',
14-
'cover' => 'Cover',
15-
'create_new' => 'Create new',
16-
'delete' => 'Delete',
17-
'delete_selected' => 'Delete Selected',
18-
'desc' => 'Description',
19-
'edit' => 'Edit',
20-
'email' => 'Email',
21-
'find' => 'Find',
22-
'go_back' => 'Go Back',
23-
'guards' => 'Guards',
24-
'locals' => 'Title Available In',
25-
'menus' => 'Menus',
26-
'meta' => 'Meta Keywords',
27-
'middlewares' => 'MiddleWares',
28-
'model_created' => 'Model Created !',
29-
'model_deleted' => 'Model Deleted !',
3+
return [
4+
'access' => 'Access',
5+
'account' => 'Account',
6+
'action' => 'Action',
7+
'add_new' => 'Add new',
8+
'avatar' => 'Avatar',
9+
'background' => 'Background',
10+
'bio' => 'Bio',
11+
'body' => 'Body',
12+
'content' => 'Content',
13+
'control' => 'Control',
14+
'cover' => 'Cover',
15+
'icon' => 'Icon',
16+
'create_new' => 'Create new',
17+
'delete' => 'Delete',
18+
'delete_selected' => 'Delete Selected',
19+
'desc' => 'Description',
20+
'edit' => 'Edit',
21+
'email' => 'Email',
22+
'find' => 'Find',
23+
'go_back' => 'Go Back',
24+
'guards' => 'Guards',
25+
'locals' => 'Title Available In',
26+
'menus' => 'Menus',
27+
'meta' => 'Meta Keywords',
28+
'middlewares' => 'MiddleWares',
29+
'model_created' => 'Model Created !',
30+
'model_deleted' => 'Model Deleted !',
3031
'model_deleted_perm' => 'Model Deleted Permanently !',
31-
'model_updated' => 'Model Updated !',
32-
'models_deleted' => 'Models Deleted !',
33-
'name' => 'Name',
34-
'no_entries' => 'No Data To Display',
35-
'ops' => 'Operations',
36-
'pages' => 'Pages',
37-
'password' => 'Password',
38-
'perm_delete' => 'Permanently Delete',
39-
'permissions' => 'Permissions',
40-
'regex' => 'The :attribute must have an "@"',
41-
'remove_child' => 'Remove Child',
42-
'remove_page' => 'Remove Page',
43-
'restore' => 'Restore',
44-
'roles' => 'Roles',
45-
'route' => 'Route Name',
46-
'route_name' => 'Route Name',
47-
'save' => 'Save',
48-
'select_all' => 'Select All',
49-
'select_non' => 'Select Non',
50-
'status' => 'Status',
51-
'template' => 'Template',
52-
'title' => 'Title',
53-
'undo' => 'Undo',
54-
'update' => 'Update',
55-
'url' => 'Url',
56-
'url_prefix' => 'Url Prefix',
57-
'users' => 'Users',
58-
);
32+
'model_updated' => 'Model Updated !',
33+
'models_deleted' => 'Models Deleted !',
34+
'name' => 'Name',
35+
'no_entries' => 'No Data To Display',
36+
'ops' => 'Operations',
37+
'pages' => 'Pages',
38+
'password' => 'Password',
39+
'perm_delete' => 'Permanently Delete',
40+
'permissions' => 'Permissions',
41+
'regex' => 'The :attribute must have an "@"',
42+
'remove_child' => 'Remove Child',
43+
'remove_page' => 'Remove Page',
44+
'restore' => 'Restore',
45+
'roles' => 'Roles',
46+
'route' => 'Route Name',
47+
'route_name' => 'Route Name',
48+
'save' => 'Save',
49+
'select_all' => 'Select All',
50+
'select_non' => 'Select Non',
51+
'status' => 'Status',
52+
'template' => 'Template',
53+
'title' => 'Title',
54+
'undo' => 'Undo',
55+
'update' => 'Update',
56+
'url' => 'Url',
57+
'url_prefix' => 'Url Prefix',
58+
'users' => 'Users',
59+
];

src/resources/views/admin/pages/create.blade.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ class="input toggle-pad"
154154
</h3>
155155
</div>
156156
<div class="column is-10" v-show="toggleContent">
157+
{{-- icon --}}
158+
<div class="field">
159+
{{ Form::label('icon', trans('SimpleMenu::messages.icon'), ['class' => 'label']) }}
160+
<div class="control">
161+
{{ Form::text(
162+
'icon',
163+
null,
164+
['class' => 'input', 'placeholder' => "icon-name or html"])
165+
}}
166+
</div>
167+
</div>
168+
157169
{{-- title --}}
158170
<div class="field">
159171
{{ Form::label('title', trans('SimpleMenu::messages.title'), ['class' => 'label']) }}
@@ -333,4 +345,4 @@ class="input toggle-pad"
333345
{{ Form::close() }}
334346
</div>
335347
</sm-page>
336-
@endsection
348+
@endsection

src/resources/views/admin/pages/edit.blade.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ class="input toggle-pad"
214214
</h3>
215215
</div>
216216
<div class="column is-10" v-show="toggleContent">
217+
{{-- icon --}}
218+
<div class="field">
219+
{{ Form::label('icon', trans('SimpleMenu::messages.icon'), ['class' => 'label']) }}
220+
<div class="control">
221+
{{ Form::text(
222+
'icon',
223+
$page->icon,
224+
['class' => 'input', 'placeholder' => "icon-name or html"])
225+
}}
226+
</div>
227+
</div>
228+
217229
{{-- title --}}
218230
<div class="field">
219231
{{ Form::label('title', trans('SimpleMenu::messages.title'), ['class' => 'label']) }}
@@ -406,4 +418,4 @@ class="input toggle-pad"
406418
{{ Form::close() }}
407419
</div>
408420
</sm-page>
409-
@endsection
421+
@endsection

0 commit comments

Comments
 (0)