Permalink
Browse files

Admin - Restructure accounts, move administrators and add 'is_preview…

…' settings
  • Loading branch information...
bpocallaghan committed Jun 1, 2018
1 parent b4c7212 commit b0d65745116d1d5216fd25c0e7868f37c075b895
@@ -11,8 +11,9 @@ A Laravel CMS Starter project with AdminLTE theme and core features.
- Password: github
### What is New?
- Upgraded to Laravel 5.5 and added many new 'components (blog, news, banners, etc)'
- Upgraded to Laravel 5.6 and added many new 'components (blog, news, banners, etc)'
- Page Builder (CRUD website pages with 3 different components)
- Add config/app.php - "is_preview". This is to prevent users to delete pages and users from the demo site.
## Features / What it includes
- Admin LTE admin theme
@@ -0,0 +1,131 @@
<?php
namespace App\Http\Controllers\Admin\Accounts;
use App\Http\Controllers\Admin\AdminController;
use App\Mail\AdminInvitRegistration;
use App\Models\Role;
use App\Models\UserInvite;
use App\User;
use App\Models\UsersInvite;
use Illuminate\Http\Request;
use Mail;
use Titan\Controllers\TitanAdminController;
class AdministratorsController extends AdminController
{
/**
* Show all the administrators
*
* @return mixed
*/
public function index()
{
save_resource_url();
$items = User::with('roles')->whereRole(Role::$BASE_ADMIN)->get();
return $this->view('accounts.administrators.index', compact('items'));
}
/**
* Show the invites
*
* @return mixed
*/
public function showInvites()
{
$items = UserInvite::orderBy('created_at')->get();
return $this->view('accounts.administrators.invite')->with('items', $items);
}
/**
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function postInvite(Request $request)
{
$this->validate($request, [
'email' => 'required|email|unique:users' // |unique:user_invites
]);
// if already exist - send invite again
$row = UserInvite::where('email', input('email'))->first();
if (!$row) {
// create row
$row = UserInvite::create([
'email' => input('email'),
'token' => '-',
'invited_by' => user()->id,
]);
}
// send mail to email
Mail::send(new AdminInvitRegistration($row));
notify()->success('Success', 'Invitation sent to ' . $row->email,
'thumbs-up bounce animated');
return redirect_to_resource();
}
/**
* Show the form for editing the specified faq.
*
* @param User $administrator
* @return Response
*/
public function edit(User $administrator)
{
$roles = Role::getAllLists();
return $this->view('accounts.administrators.create_edit', compact('roles'))
->with('item', $administrator);
}
/**
* Update the specified faq in storage.
* @param User $administrator
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(User $administrator, Request $request)
{
$this->validate($request, [
'firstname' => 'required',
'lastname' => 'required',
'roles' => 'required|array',
]);
$this->updateEntry($administrator, $request->only([
'firstname',
'lastname',
'cellphone',
'telephone',
'born_at'
]));
$administrator->roles()->sync(input('roles'));
return redirect_to_resource();
}
/**
* Remove the specified faq from storage.
* @param User $administrator
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function destroy(User $administrator, Request $request)
{
if ($administrator->id <= 3) {
notify()->warning('Whoops', 'You can not delete this user.');
}
else {
$this->deleteEntry($administrator, $request);
}
return redirect_to_resource();
}
}
@@ -119,8 +119,8 @@ public function update(Page $page)
public function destroy(Page $page)
{
// for the showcase - do not delete 'active' pages
if ($page->id < 30) {
notify()->error('Whoops', "Did you really try to delete this page?");
if (config('app.is_preview') || $page->id < 30) {
notify()->error('Whoops', "Site is in 'preview' mode. Please disable or nice try...");
return redirect_to_resource();
}
@@ -150,6 +150,13 @@ public function update($id, Request $request)
*/
public function destroy($id, Request $request)
{
// for the showcase - do not delete 'active' pages
if (config('app.is_preview') || $id < 58) {
notify()->error('Whoops', "Site is in 'preview' mode. Please disable or nice try...");
return redirect_to_resource();
}
$navigation = NavigationAdmin::findOrFail($id);
$this->deleteEntry($navigation, $request);
@@ -18,7 +18,7 @@ class AuthenticateAdmin
public function handle($request, Closure $next, $guard = null)
{
// not logged in as an admin - logout and go home
if (!user()->isBaseAdmin()) {
if (!user()->isAdmin()) {
\Auth::logout();
return redirect()->guest('/');
@@ -11,7 +11,7 @@
* On /admin login validation and all /admin navigation
* @return bool
*/
public function isBaseAdmin()
public function isAdmin()
{
return $this->hasRole(Role::$BASE_ADMIN);
}
@@ -20,7 +20,7 @@ public function isBaseAdmin()
* If User is admin
* @return bool
*/
public function isAdmin()
public function isSuperAdmin()
{
return $this->hasRole(Role::$ADMIN);
}
@@ -11,6 +11,11 @@
'google_analytics' => env('GOOGLE_ANALYTICS', ''),
'google_map_key' => env('GOOGLE_MAP_KEY', ''),
// https://github.com/bpocallaghan/laravel-admin-starter
// This will add the 'preview' text / user roles validation
// Set to false or remove key will ignore the 'preview' settings
'is_preview' => true,
'debug_blacklist' => [
'_ENV' => array_keys($_ENV),
'_COOKIE' => array_keys($_COOKIE),
@@ -20,15 +20,15 @@ public function run()
// basic user (website or/and admin or any other accounts)
Role::create([
'icon' => 'user',
'name' => 'Base User',
'name' => 'User',
'slug' => '/',
'keyword' => 'user',
]);
// base admin role (to be able to log into /admin)
Role::create([
'icon' => 'user-secret',
'name' => 'Basic Admin',
'name' => 'Base Admin',
'slug' => '/admin',
'keyword' => 'base_admin',
]);
@@ -81,7 +81,10 @@ public function run(Faker\Generator $faker)
*/
private function addAllRolesToUser($user)
{
$roles = Role::all()->pluck('keyword', 'id')->values();
// only 2 - to 5 are needed
$roles = Role::whereBetween('id', [2, 5])
->pluck('keyword', 'id')
->values();
$user->syncRoles($roles);
}
@@ -1,58 +1,59 @@
id,title,description,slug,url,icon,help_index_title,help_index_content,help_create_title,help_create_content,help_edit_title,help_edit_content,list_order,is_hidden,parent_id,url_parent_id,roles,
1,Dashboard,Dashboard,/,/admin,dashboard,,,,,,,1,0,0,0,2,
2,Analytics,Google Analytics,analytics,/admin/analytics,line-chart,,,,,,,11,0,0,0,"3,4",
3,Summary,,,/admin/analytics,star-half-o,,,,,,,2,0,2,2,"3,4",
4,Devices,,devices,/admin/analytics/devices,tablet,,,,,,,1,0,2,2,"3,4",
5,Demographics,,demographics,/admin/analytics/demographics,female,,,,,,,4,0,2,2,"3,4",
6,Visits and Referrals,,visits-and-referrals,/admin/analytics/visits-and-referrals,cloud,,,,,,,5,0,2,2,"3,4",
7,Interests,,interests,/admin/analytics/interests,heart,,,,,,,3,0,2,2,"3,4",
8,Latest Activity,Latest Activity,latest-activity,/admin/latest-activity,history,,,,,,,2,0,0,0,4,
9,Website,,website,/admin/latest-activity/website,home,,,,,,,1,0,8,8,4,
10,Admin,Admin,admin,/admin/latest-activity/admin,lock,,,,,,,2,0,8,8,4,
11,Testimonials,Testimonials,testimonials,/admin/general/testimonials,commenting-o,Info,List of all the testimonials on the website,How,Please complete the form to create the testimonial,How,Please complete the form to edit the selected testimonial,3,0,17,17,4,
12,Locations,,locations,/admin/general/locations,globe,,,,,,,6,0,17,17,4,
13,Countries,Countries,countries,/admin/general/locations/countries,map-marker,,,,,,,4,0,12,12,4,
14,Provinces,Provinces,provinces,/admin/general/locations/provinces,map-marker,,,,,,,3,0,12,12,4,
15,Cities,,cities,/admin/general/locations/cities,map-marker,,,,,,,2,0,12,12,4,
16,Suburbs,,suburbs,/admin/general/locations/suburbs,map-marker,,,,,,,1,0,12,12,4,
17,General,General Website,general,/admin/general,cubes,,,,,,,3,0,0,0,4,
18,Reports,,reports,/admin/reports,bar-chart,,,,,,,12,0,0,0,4,
19,Summary,,summary,/admin/reports/summary,align-left,,,,,,,1,0,18,18,4,
20,Contact Us,,contact-us,/admin/reports/contact-us,comments-o,,,,,,,2,0,18,18,4,
21,Settings,,settings,/admin/settings,cogs,,,,,,,13,0,0,0,4,
22,Subscription Plans,Subscription Plans,subscription-plans,/admin/settings/subscription-plans,money,,,,,,,3,0,21,21,4,
23,Features,Features,features,/admin/settings/subscription-plans/features,tags,,,,,,,4,1,22,22,4,
24,Pages,Pages,pages,/admin/pages,navicon,Help,All the menu items for the website.,Help,You can set the HTML Title and HTML Description.<br/>You can select the parent (under which navigation is this item).<br/>You can specify if the menu is hidden.,,,4,0,0,0,4,
25,Changelogs,,changelogs,/admin/settings/changelogs,file-text-o,,,,,,,2,0,21,21,4,
26,Navigation,,navigation,/admin/settings/navigation,align-center,Help,Helpfull text here - explaining what u can do here...,Information,Please complete the form to create the navigation,,,6,0,21,21,4,
27,Administrators,,administrators,/admin/settings/administrators,users,,,,,,,7,0,21,21,4,
28,Admin Invites,,invites,/admin/settings/administrators/invites,,,,,,,,1,1,27,27,4,
29,Profile,,profile,/admin/profile,user,,,,,,,14,1,0,0,4,
30,Navigation Order,Navigation Order,order,/admin/settings/navigation/order,list-ol,,,,,,,1,1,26,26,4,
31,Navigation Order,Navigation Order,order,/admin/pages/order,list-ol,,,,,,,1,1,24,24,4,
32,Banners,Banners,banners,/admin/general/banners,image,,,,,,,2,0,17,17,4,
33,Corporate,Corporate,corporate,/admin/corporate,bank,,,,,,,8,0,0,0,4,
34,Roles,Roles,roles,/admin/settings/roles,universal-access,,,,,,,1,0,21,21,4,
35,Tenders,Tenders,tenders,/admin/corporate/tenders,tags,,,,,,,1,0,33,33,4,
36,Blog,Blog,blog,/admin/blog,newspaper-o,,,,,,,6,0,0,0,4,
37,Articles,Articles,articles,/admin/blog/articles,newspaper-o,,,,,,,1,0,36,36,4,
38,Categories,Categories,categories,/admin/blog/categories,cubes,,,,,,,2,0,36,36,4,
39,Tags,Tags,tags,/admin/general/tags,tags,,,,,,,1,0,17,17,4,
40,FAQ,FAQ,faqs,/admin/faqs,question,,,,,,,9,0,0,0,4,
41,FAQ Questions,FAQ Questions,,/admin/faqs,question,,,,,,,2,0,40,40,4,
42,Categories,Categories,categories,/admin/faqs/categories,cubes,,,,,,,1,0,40,40,4,
43,Vacancies,Vacancies,vacancies,/admin/corporate/vacancies,vcard-o,,,,,,,2,0,33,33,4,
44,Annual Reports,Annual Reports,annual-reports,/admin/corporate/annual-reports,files-o,,,,,,,3,0,33,33,4,
45,News and Events,News and Events,news-and-events,/admin/news-and-events,newspaper-o,,,,,,,7,0,0,0,4,
46,News and Events,News and Events,news,/admin/news-and-events/news,newspaper-o,,,,,,,2,0,45,45,4,
47,Categories,Categories,categories,/admin/news-and-events/categories,cubes,,,,,,,1,0,45,45,4,
48,Gallery,Images,photos,/admin/photos,image,,,,,,,5,0,0,0,4,
49,Photos,Photos,,/admin/photos,image,,,,,,,2,0,48,48,4,
50,Albums,Albums,albums,/admin/photos/albums,cubes,,,,,,,1,0,48,48,4,
51,Settings,Settings,settings,/admin/settings/settings,cog,,,,,,,5,0,21,21,4,
52,Newsletter,Newsletter,newsletter,/admin/newsletter,newspaper-o,,,,,,,10,0,0,0,4,
53,Subscribers,Newsletter Subscribers,subscribers,/admin/newsletter/subscribers,users,,,,,,,1,0,52,525,4,
54,Clients,Clients,clients,/admin/general/clients,users,,,,,,,5,0,17,17,4,
55,Documents,Documents,documents,/admin/documents,files-o,,,,,,,10,0,0,0,4,
56,Categories,Categories,categories,/admin/documents/categories,cubes,,,,,,,1,0,55,55,4,
57,Documents,Documents,,/admin/documents,file-o,,,,,,,2,0,55,55,4,
id,title,description,slug,url,icon,help_index_title,help_index_content,help_create_title,help_create_content,help_edit_title,help_edit_content,list_order,is_hidden,parent_id,url_parent_id,roles
1,Dashboard,Dashboard,/,/admin,dashboard,,,,,,,1,0,0,0,2
2,Analytics,Google Analytics,analytics,/admin/analytics,line-chart,,,,,,,13,0,0,0,"3,6"
3,Summary,,,/admin/analytics,star-half-o,,,,,,,2,0,2,2,"3,6"
4,Devices,,devices,/admin/analytics/devices,tablet,,,,,,,1,0,2,2,"3,6"
5,Demographics,,demographics,/admin/analytics/demographics,female,,,,,,,4,0,2,2,"3,6"
6,Visits and Referrals,,visits-and-referrals,/admin/analytics/visits-and-referrals,cloud,,,,,,,5,0,2,2,"3,6"
7,Interests,,interests,/admin/analytics/interests,heart,,,,,,,3,0,2,2,"3,6"
8,Latest Activity,Latest Activity,latest-activity,/admin/latest-activity,history,,,,,,,2,0,0,0,4
9,Website,,website,/admin/latest-activity/website,home,,,,,,,1,0,8,8,4
10,Admin,Admin,admin,/admin/latest-activity/admin,lock,,,,,,,2,0,8,8,4
11,Testimonials,Testimonials,testimonials,/admin/general/testimonials,commenting-o,Info,List of all the testimonials on the website,How,Please complete the form to create the testimonial,How,Please complete the form to edit the selected testimonial,3,0,17,17,4
12,Locations,,locations,/admin/general/locations,globe,,,,,,,4,0,17,17,4
13,Countries,Countries,countries,/admin/general/locations/countries,map-marker,,,,,,,4,0,12,12,4
14,Provinces,Provinces,provinces,/admin/general/locations/provinces,map-marker,,,,,,,3,0,12,12,4
15,Cities,,cities,/admin/general/locations/cities,map-marker,,,,,,,2,0,12,12,4
16,Suburbs,,suburbs,/admin/general/locations/suburbs,map-marker,,,,,,,1,0,12,12,4
17,General,General Website,general,/admin/general,cubes,,,,,,,3,0,0,0,4
18,Reports,,reports,/admin/reports,bar-chart,,,,,,,14,0,0,0,4
19,Summary,,summary,/admin/reports/summary,align-left,,,,,,,1,0,18,18,4
20,Contact Us,,contact-us,/admin/reports/contact-us,comments-o,,,,,,,2,0,18,18,4
21,Settings,,settings,/admin/settings,cogs,,,,,,,15,0,0,0,4
22,Subscription Plans,Subscription Plans,subscription-plans,/admin/settings/subscription-plans,money,,,,,,,5,0,21,21,4
23,Features,Features,features,/admin/settings/subscription-plans/features,tags,,,,,,,1,1,22,22,4
24,Pages,Pages,pages,/admin/pages,navicon,Help,All the menu items for the website.,Help,You can set the HTML Title and HTML Description.<br/>You can select the parent (under which navigation is this item).<br/>You can specify if the menu is hidden.,,,4,0,0,0,4
25,Changelogs,,changelogs,/admin/settings/changelogs,file-text-o,,,,,,,3,0,21,21,4
26,Navigation,,navigation,/admin/settings/navigation,align-center,Help,Helpfull text here - explaining what u can do here...,Information,Please complete the form to create the navigation,,,4,0,21,21,4
27,Administrators,,administrators,/admin/accounts/administrators,users,,,,,,,2,0,58,58,4
28,Admin Invites,,invites,/admin/accounts/administrators/invites,,,,,,,,1,1,27,27,4
29,Profile,,profile,/admin/profile,user,,,,,,,16,1,0,0,4
30,Navigation Order,Navigation Order,order,/admin/settings/navigation/order,list-ol,,,,,,,1,1,26,26,4
31,Navigation Order,Navigation Order,order,/admin/pages/order,list-ol,,,,,,,1,1,24,24,4
32,Banners,Banners,banners,/admin/general/banners,image,,,,,,,2,0,17,17,4
33,Corporate,Corporate,corporate,/admin/corporate,bank,,,,,,,9,0,0,0,4
34,Roles,Roles,roles,/admin/settings/roles,universal-access,,,,,,,1,0,21,21,4
35,Tenders,Tenders,tenders,/admin/corporate/tenders,tags,,,,,,,1,0,33,33,4
36,Blog,Blog,blog,/admin/blog,newspaper-o,,,,,,,7,0,0,0,4
37,Articles,Articles,articles,/admin/blog/articles,newspaper-o,,,,,,,1,0,36,36,4
38,Categories,Categories,categories,/admin/blog/categories,cubes,,,,,,,2,0,36,36,4
39,Tags,Tags,tags,/admin/general/tags,tags,,,,,,,1,0,17,17,4
40,FAQ,FAQ,faqs,/admin/faqs,question,,,,,,,10,0,0,0,4
41,FAQ Questions,FAQ Questions,,/admin/faqs,question,,,,,,,2,0,40,40,4
42,Categories,Categories,categories,/admin/faqs/categories,cubes,,,,,,,1,0,40,40,4
43,Vacancies,Vacancies,vacancies,/admin/corporate/vacancies,vcard-o,,,,,,,2,0,33,33,4
44,Annual Reports,Annual Reports,annual-reports,/admin/corporate/annual-reports,files-o,,,,,,,3,0,33,33,4
45,News and Events,News and Events,news-and-events,/admin/news-and-events,newspaper-o,,,,,,,8,0,0,0,4
46,News and Events,News and Events,news,/admin/news-and-events/news,newspaper-o,,,,,,,2,0,45,45,4
47,Categories,Categories,categories,/admin/news-and-events/categories,cubes,,,,,,,1,0,45,45,4
48,Gallery,Images,photos,/admin/photos,image,,,,,,,6,0,0,0,4
49,Photos,Photos,,/admin/photos,image,,,,,,,2,0,48,48,4
50,Albums,Albums,albums,/admin/photos/albums,cubes,,,,,,,1,0,48,48,4
51,Settings,Settings,settings,/admin/settings/settings,cog,,,,,,,2,0,21,21,4
52,Newsletter,Newsletter,newsletter,/admin/newsletter,newspaper-o,,,,,,,11,0,0,0,4
53,Subscribers,Newsletter Subscribers,subscribers,/admin/newsletter/subscribers,users,,,,,,,1,0,52,52,4
54,Clients,Clients,clients,/admin/accounts/clients,users,,,,,,,1,0,58,58,4
55,Documents,Documents,documents,/admin/documents,files-o,,,,,,,12,0,0,0,4
56,Categories,Categories,categories,/admin/documents/categories,cubes,,,,,,,1,0,55,55,4
57,Documents,Documents,,/admin/documents,file-o,,,,,,,2,0,55,55,4
58,Accounts,Accounts,accounts,/admin/accounts,users,,,,,,,5,0,0,0,4
Oops, something went wrong.

0 comments on commit b0d6574

Please sign in to comment.