Unverified Commit 9f46d982 authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #142 from viralsolani/develop

Test Cases & Major Refactoring
parents 741aea63 1b867e39
...@@ -12,6 +12,10 @@ DB_DATABASE=homestead ...@@ -12,6 +12,10 @@ DB_DATABASE=homestead
DB_USERNAME=homestead DB_USERNAME=homestead
DB_PASSWORD=secret DB_PASSWORD=secret
# Access
ENABLE_REGISTRATION=true
REQUIRES_APPROVAL=false
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=file
SESSION_DRIVER=file SESSION_DRIVER=file
......
...@@ -17,6 +17,25 @@ function generateUuid() ...@@ -17,6 +17,25 @@ function generateUuid()
return uuid::uuid4(); return uuid::uuid4();
} }
if (!function_exists('homeRoute')) {
/**
* Return the route to the "home" page depending on authentication/authorization status.
*
* @return string
*/
function homeRoute()
{
if (access()->allow('view-backend')) {
return 'admin.dashboard';
} elseif (auth()->check()) {
return 'frontend.user.dashboard';
}
return 'frontend.index';
}
}
/* /*
* Global helpers file with misc functions. * Global helpers file with misc functions.
*/ */
......
...@@ -57,49 +57,49 @@ class BlogCategoriesController extends Controller ...@@ -57,49 +57,49 @@ class BlogCategoriesController extends Controller
$this->blogcategory->create($request->all()); $this->blogcategory->create($request->all());
return redirect() return redirect()
->route('admin.blogcategories.index') ->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.created')); ->with('flash_success', trans('alerts.backend.blogcategories.created'));
} }
/** /**
* @param \App\Models\BlogCategories\BlogCategory $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(BlogCategory $blogcategory, EditBlogCategoriesRequest $request) public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{ {
return view('backend.blogcategories.edit') return view('backend.blogcategories.edit')
->with('blogcategory', $blogcategory); ->with('blogcategory', $blogCategory);
} }
/** /**
* @param \App\Models\BlogCategories\BlogCategory $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(BlogCategory $blogcategory, UpdateBlogCategoriesRequest $request) public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request)
{ {
$this->blogcategory->update($blogcategory, $request->all()); $this->blogcategory->update($blogCategory, $request->all());
return redirect() return redirect()
->route('admin.blogcategories.index') ->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.updated')); ->with('flash_success', trans('alerts.backend.blogcategories.updated'));
} }
/** /**
* @param \App\Models\BlogCategories\BlogCategory $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function destroy(BlogCategory $blogcategory, DeleteBlogCategoriesRequest $request) public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request)
{ {
$this->blogcategory->delete($blogcategory); $this->blogcategory->delete($blogCategory);
return redirect() return redirect()
->route('admin.blogcategories.index') ->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted')); ->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
} }
} }
...@@ -60,49 +60,49 @@ class BlogTagsController extends Controller ...@@ -60,49 +60,49 @@ class BlogTagsController extends Controller
$this->blogtag->create($request->except('token')); $this->blogtag->create($request->except('token'));
return redirect() return redirect()
->route('admin.blogtags.index') ->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.created')); ->with('flash_success', trans('alerts.backend.blogtags.created'));
} }
/** /**
* @param \App\Models\BlogTags\BlogTag $blogtag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(BlogTag $blogtag, EditBlogTagsRequest $request) public function edit(BlogTag $blogTag, EditBlogTagsRequest $request)
{ {
return view('backend.blogtags.edit') return view('backend.blogtags.edit')
->with('blogtag', $blogtag); ->with('blogtag', $blogTag);
} }
/** /**
* @param \App\Models\BlogTags\BlogTag $blogtag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(BlogTag $blogtag, UpdateBlogTagsRequest $request) public function update(BlogTag $blogTag, UpdateBlogTagsRequest $request)
{ {
$this->blogtag->update($blogtag, $request->except(['_method', '_token'])); $this->blogtag->update($blogTag, $request->except(['_method', '_token']));
return redirect() return redirect()
->route('admin.blogtags.index') ->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.updated')); ->with('flash_success', trans('alerts.backend.blogtags.updated'));
} }
/** /**
* @param \App\Models\BlogTags\BlogTag $blogtag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function destroy(BlogTag $blogtag, DeleteBlogTagsRequest $request) public function destroy(BlogTag $blogTag, DeleteBlogTagsRequest $request)
{ {
$this->blogtag->delete($blogtag); $this->blogtag->delete($blogTag);
return redirect() return redirect()
->route('admin.blogtags.index') ->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.deleted')); ->with('flash_success', trans('alerts.backend.blogtags.deleted'));
} }
} }
...@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Pages; ...@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Pages;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Pages\ManagePageRequest; use App\Http\Requests\Backend\Pages\ManagePageRequest;
use App\Repositories\Backend\Pages\PagesRepository; use App\Repositories\Backend\Pages\PagesRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Facades\DataTables;
/** /**
...@@ -32,17 +31,17 @@ class PagesTableController extends Controller ...@@ -32,17 +31,17 @@ class PagesTableController extends Controller
{ {
return Datatables::of($this->pages->getForDataTable()) return Datatables::of($this->pages->getForDataTable())
->escapeColumns(['title']) ->escapeColumns(['title'])
->addColumn('status', function ($pages) { ->addColumn('status', function ($page) {
return $pages->status_label; return $page->status_label;
}) })
->addColumn('created_at', function ($pages) { ->addColumn('created_at', function ($page) {
return Carbon::parse($pages->created_at)->toDateString(); return $page->created_at->toDateString();
}) })
->addColumn('updated_at', function ($pages) { ->addColumn('created_by', function ($page) {
return Carbon::parse($pages->updated_at)->toDateString(); return $page->created_by;
}) })
->addColumn('actions', function ($pages) { ->addColumn('actions', function ($page) {
return $pages->action_buttons; return $page->action_buttons;
}) })
->make(true); ->make(true);
} }
......
...@@ -7,7 +7,6 @@ use App\Http\Requests\Backend\Settings\ManageSettingsRequest; ...@@ -7,7 +7,6 @@ use App\Http\Requests\Backend\Settings\ManageSettingsRequest;
use App\Http\Requests\Backend\Settings\UpdateSettingsRequest; use App\Http\Requests\Backend\Settings\UpdateSettingsRequest;
use App\Models\Settings\Setting; use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository; use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/** /**
* Class SettingsController. * Class SettingsController.
...@@ -50,22 +49,4 @@ class SettingsController extends Controller ...@@ -50,22 +49,4 @@ class SettingsController extends Controller
->route('admin.settings.edit', $setting->id) ->route('admin.settings.edit', $setting->id)
->with('flash_success', trans('alerts.backend.settings.updated')); ->with('flash_success', trans('alerts.backend.settings.updated'));
} }
/**
* @param Setting $setting
* @param Request $request
* Remove logo or favicon icon
*
* @return mixed
*/
public function removeIcon(Request $request)
{
$this->settings->removeicon($request->data);
return json_encode(
[
'status' => true,
]
);
}
} }
<?php
namespace App\Http\Controllers\Backend\Settings;
use App\Http\Controllers\Controller;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/**
* Class SettingsLogoController.
*/
class SettingsLogoController extends Controller
{
protected $settings;
/**
* @param \App\Repositories\Backend\Settings\SettingsRepository $settings
*/
public function __construct(SettingsRepository $settings)
{
$this->settings = $settings;
}
/**
* Remove logo or favicon icon.
*
* @param \App\Models\Settings\Setting $setting
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
public function destroy(Setting $setting, Request $request)
{
$this->settings->removeLogo($setting, $request->data);
return json_encode([
'status' => true,
]);
}
}
...@@ -50,7 +50,7 @@ class RegisterController extends Controller ...@@ -50,7 +50,7 @@ class RegisterController extends Controller
*/ */
public function register(RegisterRequest $request) public function register(RegisterRequest $request)
{ {
if (config('access.users.confirm_email')) { /*if (config('access.users.confirm_email')) {
$user = $this->user->create($request->all()); $user = $this->user->create($request->all());
event(new UserRegistered($user)); event(new UserRegistered($user));
...@@ -59,6 +59,22 @@ class RegisterController extends Controller ...@@ -59,6 +59,22 @@ class RegisterController extends Controller
access()->login($this->user->create($request->all())); access()->login($this->user->create($request->all()));
event(new UserRegistered(access()->user())); event(new UserRegistered(access()->user()));
return redirect($this->redirectPath());
}*/
if (config('access.users.confirm_email') || config('access.users.requires_approval')) {
$user = $this->user->create($request->only('first_name', 'last_name', 'email', 'password', 'is_term_accept'));
event(new UserRegistered($user));
return redirect($this->redirectPath())->withFlashSuccess(
config('access.users.requires_approval') ?
trans('exceptions.frontend.auth.confirmation.created_pending') :
trans('exceptions.frontend.auth.confirmation.created_confirm')
);
} else {
access()->login($this->user->create($request->only('first_name', 'last_name', 'email', 'password', 'is_term_accept')));
event(new UserRegistered(access()->user()));
return redirect($this->redirectPath()); return redirect($this->redirectPath());
} }
} }
......
...@@ -50,9 +50,20 @@ class ResetPasswordController extends Controller ...@@ -50,9 +50,20 @@ class ResetPasswordController extends Controller
*/ */
public function showResetForm($token = null) public function showResetForm($token = null)
{ {
if (!$token) {
return redirect()->route('frontend.auth.password.email');
}
$user = $this->user->findByPasswordResetToken($token);
if ($user && app()->make('auth.password.broker')->tokenExists($user, $token)) {
return view('frontend.auth.passwords.reset') return view('frontend.auth.passwords.reset')
->withToken($token) ->withToken($token)
->withEmail($this->user->getEmailForPasswordToken($token)); ->withEmail($user->email);
}
return redirect()->route('frontend.auth.password.email')
->withFlashDanger(trans('exceptions.frontend.auth.password.reset_problem'));
} }
/** /**
...@@ -80,4 +91,16 @@ class ResetPasswordController extends Controller ...@@ -80,4 +91,16 @@ class ResetPasswordController extends Controller
'password.regex' => 'Password must contain at least 1 uppercase letter and 1 number.', 'password.regex' => 'Password must contain at least 1 uppercase letter and 1 number.',
]; ];
} }
/**
* Get the response for a successful password reset.
*
* @param string $response
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetResponse($response)
{
return redirect()->route(homeRoute())->withFlashSuccess(trans($response));
}
} }
...@@ -26,9 +26,22 @@ class StoreRoleRequest extends Request ...@@ -26,9 +26,22 @@ class StoreRoleRequest extends Request
*/ */
public function rules() public function rules()
{ {
$permissions = '';
if ($this->associated_permissions != 'all') {
$permissions = 'required';
}
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => 'required', 'permissions' => $permissions,
];
}
public function messages()
{
return [
'permissions.required' => 'You must select at least one permission for this role.',
]; ];
} }
} }
...@@ -26,9 +26,22 @@ class UpdateRoleRequest extends Request ...@@ -26,9 +26,22 @@ class UpdateRoleRequest extends Request
*/ */
public function rules() public function rules()
{ {
$permissions = '';
if ($this->associated_permissions != 'all') {
$permissions = 'required';
}
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => 'required', 'permissions' => $permissions,
];
}
public function messages()
{
return [
'permissions.required' => 'You must select at least one permission for this role.',
]; ];
} }
} }
...@@ -30,6 +30,14 @@ class UserEventListener ...@@ -30,6 +30,14 @@ class UserEventListener
* @param $event * @param $event
*/ */
public function onRegistered($event) public function onRegistered($event)
{
\Log::info('User Registered: '.$event->user->full_name);
}
/**
* @param $event
*/
/*public function onRegistered($event)
{ {
\Log::info('User Registered: '.$event->user->first_name); \Log::info('User Registered: '.$event->user->first_name);
...@@ -39,7 +47,7 @@ class UserEventListener ...@@ -39,7 +47,7 @@ class UserEventListener
'email_template_type' => 1, 'email_template_type' => 1,
]; ];
createNotification('', 1, 2, $options); createNotification('', 1, 2, $options);
} }*/
/** /**
* @param $event * @param $event
......
...@@ -213,9 +213,9 @@ trait UserAttribute ...@@ -213,9 +213,9 @@ trait UserAttribute
/** /**
* @return string * @return string
*/ */
public function getDeletePermanentlyButtonAttribute() public function getDeletePermanentlyButtonAttribute($class)
{ {
return '<a href="'.route('admin.access.user.delete-permanently', $this).'" name="delete_user_perm"><i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.delete_permanently').'"></i></a> '; return '<a class="'.$class.'" href="'.route('admin.access.user.delete-permanently', $this).'" name="delete_user_perm"><i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.delete_permanently').'"></i></a> ';
} }
/** /**
...@@ -383,7 +383,10 @@ trait UserAttribute ...@@ -383,7 +383,10 @@ trait UserAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
if ($this->trashed()) { if ($this->trashed()) {
return '<div class="btn-group action-btn">'.$this->getRestoreButtonAttribute('btn btn-default btn-flat').'</div>'; return '<div class="btn-group action-btn">
'.$this->getRestoreButtonAttribute('btn btn-default btn-flat').'
'.$this->getDeletePermanentlyButtonAttribute('btn btn-default btn-flat').'
</div>';
} }
// Check if role have all permission // Check if role have all permission
......
...@@ -13,8 +13,8 @@ trait BlogCategoryAttribute ...@@ -13,8 +13,8 @@ trait BlogCategoryAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogcategories.edit').' '.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogCategories.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogcategories.destroy').' '.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogCategories.destroy').'
</div>'; </div>';
} }
......
...@@ -12,8 +12,8 @@ trait BlogCategoryRelationship ...@@ -12,8 +12,8 @@ trait BlogCategoryRelationship
/** /**
* BlogCategories belongs to relationship with state. * BlogCategories belongs to relationship with state.
*/ */
public function createdBy() public function creator()
{ {
return $this->belongsTo(User::class, 'created_by', 'id'); return $this->belongsTo(User::class, 'created_by');
} }
} }
...@@ -13,8 +13,8 @@ trait BlogTagAttribute ...@@ -13,8 +13,8 @@ trait BlogTagAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogtags.edit').' '.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogTags.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogtags.destroy').' '.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogTags.destroy').'
</div>'; </div>';
} }
......
...@@ -12,8 +12,8 @@ trait BlogTagRelationship ...@@ -12,8 +12,8 @@ trait BlogTagRelationship
/** /**
* BlogTags belongs to relationship with state. * BlogTags belongs to relationship with state.
*/ */
public function createdBy() public function creator()
{ {
return $this->belongsTo(User::class, 'created_by', 'id'); return $this->belongsTo(User::class, 'created_by');
} }
} }
...@@ -30,8 +30,8 @@ trait BlogRelationship ...@@ -30,8 +30,8 @@ trait BlogRelationship
/** /**
* Blogs belongsTo with User. * Blogs belongsTo with User.
*/ */
public function createdBy() public function owner()
{ {
return $this->belongsTo(User::class, 'created_by', 'id'); return $this->belongsTo(User::class, 'created_by');
} }
} }
...@@ -5,12 +5,14 @@ namespace App\Models\Page; ...@@ -5,12 +5,14 @@ namespace App\Models\Page;
use App\Models\BaseModel; use App\Models\BaseModel;
use App\Models\ModelTrait; use App\Models\ModelTrait;
use App\Models\Page\Traits\Attribute\PageAttribute; use App\Models\Page\Traits\Attribute\PageAttribute;
use App\Models\Page\Traits\PageRelationship;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class Page extends BaseModel class Page extends BaseModel
{ {
use ModelTrait, use ModelTrait,
SoftDeletes, SoftDeletes,
PageRelationship,
PageAttribute { PageAttribute {
// PageAttribute::getEditButtonAttribute insteadof ModelTrait; // PageAttribute::getEditButtonAttribute insteadof ModelTrait;
} }
...@@ -29,6 +31,17 @@ class Page extends BaseModel ...@@ -29,6 +31,17 @@ class Page extends BaseModel
*/ */
protected $guarded = ['id']; protected $guarded = ['id'];
/**
* The default values for attributes.
*
* @var array
*/
protected $attributes = [
'created_by' => 1,
];
protected $with = ['owner'];
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
......
...@@ -13,8 +13,8 @@ trait PageAttribute ...@@ -13,8 +13,8 @@ trait PageAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-cms-pages', 'admin.pages.edit').' '.$this->getEditButtonAttribute('edit-page', 'admin.pages.edit').'
'.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.pages.destroy').' '.$this->getDeleteButtonAttribute('delete-page', 'admin.pages.destroy').'
</div>'; </div>';
} }
......
<?php
namespace App\Models\Page\Traits;
use App\Models\Access\User\User;
trait PageRelationship
{
public function owner()
{
return $this->belongsTo(User::class, 'created_by');
}
}
...@@ -69,7 +69,7 @@ class RoleRepository extends BaseRepository ...@@ -69,7 +69,7 @@ class RoleRepository extends BaseRepository
} }
//See if the role has all access //See if the role has all access
$all = $input['associated-permissions'] == 'all' ? true : false; $all = $input['associated_permissions'] == 'all' ? true : false;
if (!isset($input['permissions'])) { if (!isset($input['permissions'])) {
$input['permissions'] = []; $input['permissions'] = [];
...@@ -133,7 +133,7 @@ class RoleRepository extends BaseRepository ...@@ -133,7 +133,7 @@ class RoleRepository extends BaseRepository
if ($role->id == 1) { if ($role->id == 1) {
$all = true; $all = true;
} else { } else {
$all = $input['associated-permissions'] == 'all' ? true : false; $all = $input['associated_permissions'] == 'all' ? true : false;
} }
if (!isset($input['permissions'])) { if (!isset($input['permissions'])) {
...@@ -190,13 +190,13 @@ class RoleRepository extends BaseRepository ...@@ -190,13 +190,13 @@ class RoleRepository extends BaseRepository
} }
/** /**
* @param Model $role * @param Role $role
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $role) public function delete(Role $role)
{ {
//Would be stupid to delete the administrator role //Would be stupid to delete the administrator role
if ($role->id == 1) { //id is 1 because of the seeder if ($role->id == 1) { //id is 1 because of the seeder
......
...@@ -97,9 +97,6 @@ class UserRepository extends BaseRepository ...@@ -97,9 +97,6 @@ class UserRepository extends BaseRepository
$user = $this->createUserStub($data); $user = $this->createUserStub($data);
DB::transaction(function () use ($user, $data, $roles, $permissions) { DB::transaction(function () use ($user, $data, $roles, $permissions) {
// Set email type 2
$email_type = 2;
if ($user->save()) { if ($user->save()) {
//User Created, Validate Roles //User Created, Validate Roles
...@@ -120,18 +117,6 @@ class UserRepository extends BaseRepository ...@@ -120,18 +117,6 @@ class UserRepository extends BaseRepository
event(new UserCreated($user)); event(new UserCreated($user));
/*if (isset($data['confirmation_email']) && $user->confirmed == 0) {
$email_type = 1;
}*/
// Send email to the user
/* $options = [
'data' => $user->toArray(),
'email_template_type' => $email_type,
];*/
//createNotification('', 1, 2, $options);
return true; return true;
} }
...@@ -175,28 +160,23 @@ class UserRepository extends BaseRepository ...@@ -175,28 +160,23 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * Change Password.
*
* @param $user
* @param $input * @param $input
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function updatePassword(Model $user, $input) public function updatePassword($user, $input)
{ {
$user = $this->find(access()->id()); $user = $this->find(access()->id());
if (Hash::check($input['old_password'], $user->password)) { if (Hash::check($input['old_password'], $user->password)) {
$user->password = bcrypt($input['password']); $user->password = bcrypt($input['password']);
if ($user->save()) {
$input['email'] = $user->email;
// Send email to the user
$options = [
'data' => $input,
'email_template_type' => 4,
];
createNotification('', $user->id, 2, $options);
if ($user->save()) {
event(new UserPasswordChanged($user)); event(new UserPasswordChanged($user));
return true; return true;
...@@ -215,7 +195,7 @@ class UserRepository extends BaseRepository ...@@ -215,7 +195,7 @@ class UserRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function delete(Model $user) public function delete($user)
{ {
if (access()->id() == $user->id) { if (access()->id() == $user->id) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_self')); throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_self'));
...@@ -231,11 +211,11 @@ class UserRepository extends BaseRepository ...@@ -231,11 +211,11 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * @param $user
* *
* @throws GeneralException * @throws GeneralException
*/ */
public function forceDelete(Model $user) public function forceDelete($user)
{ {
if (is_null($user->deleted_at)) { if (is_null($user->deleted_at)) {
throw new GeneralException(trans('exceptions.backend.access.users.delete_first')); throw new GeneralException(trans('exceptions.backend.access.users.delete_first'));
...@@ -253,13 +233,13 @@ class UserRepository extends BaseRepository ...@@ -253,13 +233,13 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * @param $user
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function restore(Model $user) public function restore($user)
{ {
if (is_null($user->deleted_at)) { if (is_null($user->deleted_at)) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_restore')); throw new GeneralException(trans('exceptions.backend.access.users.cant_restore'));
...@@ -275,14 +255,14 @@ class UserRepository extends BaseRepository ...@@ -275,14 +255,14 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * @param $user
* @param $status * @param $status
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function mark(Model $user, $status) public function mark($user, $status)
{ {
if (access()->id() == $user->id && $status == 0) { if (access()->id() == $user->id && $status == 0) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self')); throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self'));
...@@ -301,13 +281,6 @@ class UserRepository extends BaseRepository ...@@ -301,13 +281,6 @@ class UserRepository extends BaseRepository
} }
if ($user->save()) { if ($user->save()) {
// Send email to the user
$options = [
'data' => $user,
'email_template_type' => 3,
];
createNotification('', $user->id, 2, $options);
return true; return true;
} }
......
...@@ -6,7 +6,6 @@ use App\Events\Backend\Blogs\BlogCreated; ...@@ -6,7 +6,6 @@ use App\Events\Backend\Blogs\BlogCreated;
use App\Events\Backend\Blogs\BlogDeleted; use App\Events\Backend\Blogs\BlogDeleted;
use App\Events\Backend\Blogs\BlogUpdated; use App\Events\Backend\Blogs\BlogUpdated;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Http\Utilities\FileUploads;
use App\Models\BlogCategories\BlogCategory; use App\Models\BlogCategories\BlogCategory;
use App\Models\BlogMapCategories\BlogMapCategory; use App\Models\BlogMapCategories\BlogMapCategory;
use App\Models\BlogMapTags\BlogMapTag; use App\Models\BlogMapTags\BlogMapTag;
...@@ -15,6 +14,7 @@ use App\Models\BlogTags\BlogTag; ...@@ -15,6 +14,7 @@ use App\Models\BlogTags\BlogTag;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use DB;
use Illuminate\Support\Facades\Storage;
/** /**
* Class BlogsRepository. * Class BlogsRepository.
...@@ -26,6 +26,21 @@ class BlogsRepository extends BaseRepository ...@@ -26,6 +26,21 @@ class BlogsRepository extends BaseRepository
*/ */
const MODEL = Blog::class; const MODEL = Blog::class;
protected $upload_path;
/**
* Storage Class Object.
*
* @var \Illuminate\Support\Facades\Storage
*/
protected $storage;
public function __construct()
{
$this->upload_path = 'img'.DIRECTORY_SEPARATOR.'blog'.DIRECTORY_SEPARATOR;
$this->storage = Storage::disk('public');
}
/** /**
* @return mixed * @return mixed
*/ */
...@@ -132,7 +147,7 @@ class BlogsRepository extends BaseRepository ...@@ -132,7 +147,7 @@ class BlogsRepository extends BaseRepository
/** /**
* Creating Tags. * Creating Tags.
* *
* @param Array($tags) * @param array $tags
* *
* @return array * @return array
*/ */
...@@ -210,13 +225,12 @@ class BlogsRepository extends BaseRepository ...@@ -210,13 +225,12 @@ class BlogsRepository extends BaseRepository
*/ */
public function uploadImage($input) public function uploadImage($input)
{ {
$uploadManager = new FileUploads();
$avatar = $input['featured_image']; $avatar = $input['featured_image'];
if (isset($input['featured_image']) && !empty($input['featured_image'])) { if (isset($input['featured_image']) && !empty($input['featured_image'])) {
$fileName = $uploadManager->setBasePath('backend/blog_images') $fileName = time().$avatar->getClientOriginalName();
->setThumbnailFlag(false)
->upload($input['featured_image']); $this->storage->put($this->upload_path.$fileName, file_get_contents($avatar->getRealPath()));
$input = array_merge($input, ['featured_image' => $fileName]); $input = array_merge($input, ['featured_image' => $fileName]);
...@@ -231,11 +245,8 @@ class BlogsRepository extends BaseRepository ...@@ -231,11 +245,8 @@ class BlogsRepository extends BaseRepository
*/ */
public function deleteOldFile($model) public function deleteOldFile($model)
{ {
$uploadManager = new FileUploads();
$fileName = $model->featured_image; $fileName = $model->featured_image;
$filePath = $uploadManager->setBasePath('backend/blog_images');
$file = $filePath->filePath.DIRECTORY_SEPARATOR.$fileName;
return $uploadManager->deleteFile($file); return $this->storage->delete($this->upload_path.$fileName);
} }
} }
...@@ -25,12 +25,14 @@ class PagesRepository extends BaseRepository ...@@ -25,12 +25,14 @@ class PagesRepository extends BaseRepository
public function getForDataTable() public function getForDataTable()
{ {
return $this->query() return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.pages.table').'.created_by')
->select([ ->select([
config('module.pages.table').'.id', config('module.pages.table').'.id',
config('module.pages.table').'.title', config('module.pages.table').'.title',
config('module.pages.table').'.status', config('module.pages.table').'.status',
config('module.pages.table').'.created_at', config('module.pages.table').'.created_at',
config('module.pages.table').'.updated_at', config('module.pages.table').'.updated_at',
config('access.users_table').'.first_name as created_by',
]); ]);
} }
...@@ -47,10 +49,10 @@ class PagesRepository extends BaseRepository ...@@ -47,10 +49,10 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists')); throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
} }
//Making extra fields // Making extra fields
$input['page_slug'] = str_slug($input['title']); $input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0; $input['status'] = isset($input['status']) ? 1 : 0;
$input['created_by'] = access()->user()->id; $input['created_by'] = auth()->id();
if ($page = Page::create($input)) { if ($page = Page::create($input)) {
event(new PageCreated($page)); event(new PageCreated($page));
...@@ -75,7 +77,7 @@ class PagesRepository extends BaseRepository ...@@ -75,7 +77,7 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists')); throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
} }
//Making extra fields // Making extra fields
$input['page_slug'] = str_slug($input['title']); $input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0; $input['status'] = isset($input['status']) ? 1 : 0;
$input['updated_by'] = access()->user()->id; $input['updated_by'] = access()->user()->id;
......
...@@ -5,6 +5,7 @@ namespace App\Repositories\Backend\Settings; ...@@ -5,6 +5,7 @@ namespace App\Repositories\Backend\Settings;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Models\Settings\Setting; use App\Models\Settings\Setting;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\Storage;
/** /**
* Class SettingsRepository. * Class SettingsRepository.
...@@ -16,24 +17,57 @@ class SettingsRepository extends BaseRepository ...@@ -16,24 +17,57 @@ class SettingsRepository extends BaseRepository
*/ */
const MODEL = Setting::class; const MODEL = Setting::class;
/**
* Site Logo Path.
*
* @var string
*/
protected $site_logo_path;
/**
* Favicon path.
*
* @var string
*/
protected $favicon_path;
/**
* Storage Class Object.
*
* @var \Illuminate\Support\Facades\Storage
*/
protected $storage;
/**
* Constructor.
*/
public function __construct()
{
$this->site_logo_path = 'img'.DIRECTORY_SEPARATOR.'logo'.DIRECTORY_SEPARATOR;
$this->favicon_path = 'img'.DIRECTORY_SEPARATOR.'favicon'.DIRECTORY_SEPARATOR;
$this->storage = Storage::disk('public');
}
/** /**
* @param \App\Models\Settings\Setting $setting * @param \App\Models\Settings\Setting $setting
* @param $input * @param array $input
* *
* @throws \App\Exceptions\GeneralException * @throws \App\Exceptions\GeneralException
* *
* return bool * @return bool
*/ */
public function update(Setting $setting, array $input) public function update(Setting $setting, array $input)
{ {
if (isset($input['logo'])) { if (!empty($input['logo'])) {
$image_upload = $this->uploadlogoimage($setting, $input['logo']); $this->removeLogo($setting, 'logo');
$input['logo'] = $image_upload;
$input['logo'] = $this->uploadLogo($setting, $input['logo'], 'logo');
} }
if (isset($input['favicon'])) { if (!empty($input['favicon'])) {
$image_upload = $this->uploadfaviconimage($setting, $input['favicon']); $this->removeLogo($setting, 'favicon');
$input['favicon'] = $image_upload;
$input['favicon'] = $this->uploadLogo($setting, $input['favicon'], 'favicon');
} }
if ($setting->update($input)) { if ($setting->update($input)) {
...@@ -46,63 +80,34 @@ class SettingsRepository extends BaseRepository ...@@ -46,63 +80,34 @@ class SettingsRepository extends BaseRepository
/* /*
* Upload logo image * Upload logo image
*/ */
public function uploadlogoimage($setting, $logo) public function uploadLogo($setting, $logo, $type)
{ {
$image_name_ex = $logo->getClientOriginalExtension(); $path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
if ($setting->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting->logo)) {
unlink('img/site_logo/'.$setting->logo);
}
}
$image_name = time().$logo->getClientOriginalName(); $image_name = time().$logo->getClientOriginalName();
$destinationPath = public_path('img/site_logo');
$logo->move($destinationPath, $image_name); $this->storage->put($path.$image_name, file_get_contents($logo->getRealPath()));
return $image_name; return $image_name;
} }
/* /*
* Upload favicon icon image * remove logo or favicon icon
*/ */
public function uploadfaviconimage($setting, $logo) public function removeLogo(Setting $setting, $type)
{ {
$image_name_ex = $logo->getClientOriginalExtension(); $path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
if ($setting->favicon) { if ($setting->$type && $this->storage->exists($path.$setting->$type)) {
if (file_exists(public_path().'/img/favicon_icon/'.$setting->favicon)) { $this->storage->delete($path.$setting->$type);
unlink('img/favicon_icon/'.$setting->favicon);
}
} }
$image_name = time().$logo->getClientOriginalName(); $result = $setting->update([$type => null]);
$destinationPath = public_path('/img/favicon_icon');
$logo->move($destinationPath, $image_name);
return $image_name; if ($result) {
return true;
} }
/* throw new GeneralException(trans('exceptions.backend.settings.update_error'));
* remove logo or favicon icon
*/
public function removeicon($input)
{
$setting = $this->query()->get();
if ($input == 'logo') {
if ($setting[0]->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting[0]->logo)) {
unlink('img/site_logo/'.$setting[0]->logo);
}
$this->query()->update(['logo' => null]);
}
} else {
if ($setting[0]->favicon) {
if (file_exists(public_path().'/img/favicon_icon/'.$setting[0]->favicon)) {
unlink('img/favicon_icon/'.$setting[0]->favicon);
}
}
$this->query()->update(['favicon' => null]);
}
} }
} }
...@@ -79,6 +79,8 @@ class UserRepository extends BaseRepository ...@@ -79,6 +79,8 @@ class UserRepository extends BaseRepository
} }
/** /**
* Create User.
*
* @param array $data * @param array $data
* @param bool $provider * @param bool $provider
* *
...@@ -94,11 +96,28 @@ class UserRepository extends BaseRepository ...@@ -94,11 +96,28 @@ class UserRepository extends BaseRepository
$user->confirmation_code = md5(uniqid(mt_rand(), true)); $user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->status = 1; $user->status = 1;
$user->password = $provider ? null : bcrypt($data['password']); $user->password = $provider ? null : bcrypt($data['password']);
$user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1);
$user->is_term_accept = $data['is_term_accept']; $user->is_term_accept = $data['is_term_accept'];
// If users require approval, confirmed is false regardless of account type
if (config('access.users.requires_approval')) {
$user->confirmed = 0; // No confirm e-mail sent, that defeats the purpose of manual approval
} elseif (config('access.users.confirm_email')) { // If user must confirm email
// If user is from social, already confirmed
if ($provider) {
$user->confirmed = 1; // E-mails are validated through the social platform
} else {
// Otherwise needs confirmation
$user->confirmed = 0;
$confirm = true;
}
} else {
// Otherwise both are off and confirmed is default
$user->confirmed = 1;
}
DB::transaction(function () use ($user) { DB::transaction(function () use ($user) {
if ($user->save()) { if ($user->save()) {
/* /*
* Add the default site role to the new user * Add the default site role to the new user
*/ */
...@@ -304,4 +323,20 @@ class UserRepository extends BaseRepository ...@@ -304,4 +323,20 @@ class UserRepository extends BaseRepository
return $token; return $token;
} }
/**
* @param $token
*
* @return mixed
*/
public function findByPasswordResetToken($token)
{
foreach (DB::table(config('auth.passwords.users.table'))->get() as $row) {
if (password_verify($token, $row->token)) {
return $this->findByEmail($row->email);
}
}
return false;
}
} }
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
"keywords": [ "keywords": [
"framework", "framework",
"laravel", "laravel",
"boilerplate" "boilerplate",
"adminpanel",
"rest-api"
], ],
"license": "MIT", "license": "MIT",
"type": "project", "type": "project",
...@@ -12,6 +14,7 @@ ...@@ -12,6 +14,7 @@
"php": ">=7.0.0", "php": ">=7.0.0",
"arcanedev/log-viewer": "^4.4", "arcanedev/log-viewer": "^4.4",
"arcanedev/no-captcha": "^5.0", "arcanedev/no-captcha": "^5.0",
"codedungeon/phpunit-result-printer": "0.4.4",
"creativeorange/gravatar": "~1.0", "creativeorange/gravatar": "~1.0",
"davejamesmiller/laravel-breadcrumbs": "^4.1", "davejamesmiller/laravel-breadcrumbs": "^4.1",
"doctrine/dbal": "^2.6", "doctrine/dbal": "^2.6",
...@@ -54,6 +57,9 @@ ...@@ -54,6 +57,9 @@
}, },
"classmap": [ "classmap": [
"tests/TestCase.php" "tests/TestCase.php"
],
"files": [
"tests/Utilities/helpers.php"
] ]
}, },
"scripts": { "scripts": {
......
This diff is collapsed.
...@@ -88,7 +88,7 @@ return [ ...@@ -88,7 +88,7 @@ return [
/* /*
* Whether or not public registration is on * Whether or not public registration is on
*/ */
'registration' => env('ENABLE_REGISTRATION', 'true'), 'registration' => env('ENABLE_REGISTRATION', true),
/* /*
* The role the user is assigned to when they sign up from the frontend, not namespaced * The role the user is assigned to when they sign up from the frontend, not namespaced
...@@ -105,6 +105,12 @@ return [ ...@@ -105,6 +105,12 @@ return [
* Whether or not the users email can be changed on the edit profile screen * Whether or not the users email can be changed on the edit profile screen
*/ */
'change_email' => false, 'change_email' => false,
/*
* Whether or not new users need to be approved by an administrator before logging in
* If this is set to true, then confirm_email is not in effect
*/
'requires_approval' => env('REQUIRES_APPROVAL', false),
], ],
/* /*
......
<?php
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use Faker\Generator as Faker;
$factory->define(BlogCategory::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Access\User\User;
use App\Models\Blogs\Blog;
use Faker\Generator as Faker;
$factory->define(Blog::class, function (Faker $faker) {
$status = [
'Published',
'Draft',
'InActive',
'Scheduled',
];
return [
'name' => $faker->sentence,
'publish_datetime' => $faker->dateTime(),
'featured_image' => 'logo.png',
'content' => $faker->paragraph(3),
'status' => $status[$faker->numberBetween(0, 3)],
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Access\User\User;
use App\Models\BlogTags\BlogTag;
use Faker\Generator as Faker;
$factory->define(BlogTag::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Faqs\Faq;
use Faker\Generator as Faker;
$factory->define(Faq::class, function (Faker $faker) {
return [
'question' => rtrim($faker->sentence, '.').'?',
'answer' => $faker->paragraph,
'status' => $faker->numberBetween(0, 1),
];
});
<?php
use App\Models\Access\User\User;
use App\Models\Page\Page;
use Faker\Generator as Faker;
$factory->define(Page::class, function (Faker $faker) {
$title = $faker->sentence;
return [
'title' => $title,
'page_slug' => str_slug($title),
'description' => $faker->paragraph,
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Access\Permission\Permission;
use Faker\Generator;
/*
* Permissions
*/
$factory->define(Permission::class, function (Generator $faker) {
$name = $faker->word;
return [
'name' => $name,
'display_name' => $name,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Permission::class, 'active', function () {
return [
'status' => 1,
];
});
$factory->state(Permission::class, 'inactive', function () {
return [
'status' => 0,
];
});
<?php
use App\Models\Access\Role\Role;
use Faker\Generator;
/*
* Roles
*/
$factory->define(Role::class, function (Generator $faker) {
return [
'name' => $faker->name,
'all' => 0,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Role::class, 'admin', function () {
return [
'all' => 1,
];
});
$factory->state(Role::class, 'active', function () {
return [
'status' => 1,
];
});
$factory->state(Role::class, 'inactive', function () {
return [
'status' => 0,
];
});
<?php <?php
use App\Models\Access\Role\Role;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use Faker\Generator; use Faker\Generator;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function (Generator $faker) { $factory->define(User::class, function (Generator $faker) {
static $password; static $password;
return [ return [
'name' => $faker->name, 'first_name' => $faker->name,
'last_name' => $faker->name,
'email' => $faker->safeEmail, 'email' => $faker->safeEmail,
'password' => $password ?: $password = bcrypt('secret'), 'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
'remember_token' => str_random(10),
]; ];
}); });
...@@ -50,20 +39,3 @@ $factory->state(User::class, 'unconfirmed', function () { ...@@ -50,20 +39,3 @@ $factory->state(User::class, 'unconfirmed', function () {
'confirmed' => 0, 'confirmed' => 0,
]; ];
}); });
/*
* Roles
*/
$factory->define(Role::class, function (Generator $faker) {
return [
'name' => $faker->name,
'all' => 0,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Role::class, 'admin', function () {
return [
'all' => 1,
];
});
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNullConstraintOnCreatedByOnUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->integer('created_by')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNullConstraintOnCreatedByOnRoleTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('roles', function (Blueprint $table) {
$table->integer('created_by')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNullConstraintOnCreatedByOnPermissionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('permissions', function (Blueprint $table) {
$table->integer('created_by')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
...@@ -26,8 +26,8 @@ class UserTableSeeder extends Seeder ...@@ -26,8 +26,8 @@ class UserTableSeeder extends Seeder
//Add the master administrator, user id of 1 //Add the master administrator, user id of 1
$users = [ $users = [
[ [
'first_name' => 'Admin Istrator', 'first_name' => 'Viral',
'last_name' => 'Admin Istrator', 'last_name' => 'Solani',
'email' => 'admin@admin.com', 'email' => 'admin@admin.com',
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
...@@ -39,8 +39,8 @@ class UserTableSeeder extends Seeder ...@@ -39,8 +39,8 @@ class UserTableSeeder extends Seeder
'deleted_at' => null, 'deleted_at' => null,
], ],
[ [
'first_name' => 'Backend User', 'first_name' => 'Vipul',
'last_name' => 'Admin Istrator', 'last_name' => 'Basapati',
'email' => 'executive@executive.com', 'email' => 'executive@executive.com',
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
...@@ -52,8 +52,8 @@ class UserTableSeeder extends Seeder ...@@ -52,8 +52,8 @@ class UserTableSeeder extends Seeder
'deleted_at' => null, 'deleted_at' => null,
], ],
[ [
'first_name' => 'Default User', 'first_name' => 'User',
'last_name' => 'Admin Istrator', 'last_name' => 'Test',
'email' => 'user@user.com', 'email' => 'user@user.com',
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
......
...@@ -18,7 +18,7 @@ class MenuTableSeeder extends Seeder ...@@ -18,7 +18,7 @@ class MenuTableSeeder extends Seeder
'id' => 1, 'id' => 1,
'type' => 'backend', 'type' => 'backend',
'name' => 'Backend Sidebar Menu', 'name' => 'Backend Sidebar Menu',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogcategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogtags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]', 'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogCategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogTags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'created_by' => 1, 'created_by' => 1,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
]; ];
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false"> stopOnFailure="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
<testsuites> <testsuites>
<testsuite name="Feature Tests"> <testsuite name="Feature Tests">
<directory suffix="Test.php">./tests/Feature</directory> <directory suffix="Test.php">./tests/Feature</directory>
......
var associated = $("select[name='associated-permissions']"); var associated = $("select[name='associated_permissions']");
var associated_container = $("#available-permissions"); var associated_container = $("#available-permissions");
if (associated.val() == "custom") if (associated.val() == "custom")
......
{
"/js/frontend.js": "/js/frontend.945469bbbc12df3ad9e1.js",
"/js/backend.js": "/js/backend.79d9e4698dadbc0d93c7.js",
"/mix.js": "/mix.247ab120fe7680658924.js",
"/css/frontend.css": "/css/frontend.3af0a6cbd7d1d8d042f2a37e97008b7c.css",
"/css/backend.css": "/css/backend.f8550f50504e5b8ef6055285205f223a.css",
"/css/backend-custom.css": "/css/backend-custom.18e74fbe4c755b817a022d6d3d4e76b1.css",
"/js/backend-custom.js": "/js/backend-custom.e6ea05e1824d0dd8e7c62027c135b7f2.js",
"/js/dataTable.js": "/js/dataTable.f968d300a6a0b871f138f114361259c8.js"
}
\ No newline at end of file
...@@ -115,6 +115,7 @@ return [ ...@@ -115,6 +115,7 @@ return [
'already_confirmed' => 'Your account is already confirmed.', 'already_confirmed' => 'Your account is already confirmed.',
'confirm' => 'Confirm your account!', 'confirm' => 'Confirm your account!',
'created_confirm' => 'Your account was successfully created. We have sent you an e-mail to confirm your account.', 'created_confirm' => 'Your account was successfully created. We have sent you an e-mail to confirm your account.',
'created_pending' => 'Your account was successfully created and is pending approval. An e-mail will be sent when your account is approved.',
'mismatch' => 'Your confirmation code does not match.', 'mismatch' => 'Your confirmation code does not match.',
'not_found' => 'That confirmation code does not exist.', 'not_found' => 'That confirmation code does not exist.',
'resend' => 'Your account is not confirmed. Please click the confirmation link in your e-mail, or <a href='.route('frontend.auth.account.confirm.resend', ':user_id').'>click here</a> to resend the confirmation e-mail.', 'resend' => 'Your account is not confirmed. Please click the confirmation link in your e-mail, or <a href='.route('frontend.auth.account.confirm.resend', ':user_id').'>click here</a> to resend the confirmation e-mail.',
......
...@@ -66,7 +66,7 @@ return [ ...@@ -66,7 +66,7 @@ return [
'active' => 'Active Users', 'active' => 'Active Users',
'all_permissions' => 'All Permissions', 'all_permissions' => 'All Permissions',
'change_password' => 'Change Password', 'change_password' => 'Change Password',
'change_password_for' => 'Change Password :user', 'change_password_for' => 'Change Password for :user',
'create' => 'Create User', 'create' => 'Create User',
'deactivated' => 'Deactivated Users', 'deactivated' => 'Deactivated Users',
'deleted' => 'Deleted Users', 'deleted' => 'Deleted Users',
...@@ -126,6 +126,7 @@ return [ ...@@ -126,6 +126,7 @@ return [
'status' => 'Status', 'status' => 'Status',
'createdat' => 'Created At', 'createdat' => 'Created At',
'updatedat' => 'Updated At', 'updatedat' => 'Updated At',
'createdby' => 'Created By',
'all' => 'All', 'all' => 'All',
], ],
], ],
...@@ -200,7 +201,7 @@ return [ ...@@ -200,7 +201,7 @@ return [
'companydetails' => 'Company Contact Details', 'companydetails' => 'Company Contact Details',
'mail' => 'Mail Settings', 'mail' => 'Mail Settings',
'footer' => 'Footer Settings', 'footer' => 'Footer Settings',
'terms' => 'Terms & Condition Settings', 'terms' => 'Terms and Condition Settings',
'google' => 'Google Analytics Track Code', 'google' => 'Google Analytics Track Code',
], ],
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<span class="sr-only">Toggle Dropdown</span> <span class="sr-only">Toggle Dropdown</span>
</button> </button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li id="copyButton"><a href="#"><i class="fa fa-clone"></i> Copy</a></li> <li id="copyButton"><a href="#"><i class="fa fa-clone"></i>Copy</a></li>
<li id="csvButton"><a href="#"><i class="fa fa-file-text-o"></i> CSV</a></li> <li id="csvButton"><a href="#"><i class="fa fa-file-text-o"></i> CSV</a></li>
<li id="excelButton"><a href="#"><i class="fa fa-file-excel-o"></i> Excel</a></li> <li id="excelButton"><a href="#"><i class="fa fa-file-excel-o"></i> Excel</a></li>
<li id="pdfButton"><a href="#"><i class="fa fa-file-pdf-o"></i> PDF</a></li> <li id="pdfButton"><a href="#"><i class="fa fa-file-pdf-o"></i> PDF</a></li>
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
</div><!--form control--> </div><!--form control-->
<div class="form-group"> <div class="form-group">
{{ Form::label('associated-permissions', trans('validation.attributes.backend.access.roles.associated_permissions'), ['class' => 'col-lg-2 control-label']) }} {{ Form::label('associated_permissions', trans('validation.attributes.backend.access.roles.associated_permissions'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10"> <div class="col-lg-10">
{{ Form::select('associated-permissions', array('all' => trans('labels.general.all'), 'custom' => trans('labels.general.custom')), 'all', ['class' => 'form-control select2 box-size']) }} {{ Form::select('associated_permissions', array('all' => trans('labels.general.all'), 'custom' => trans('labels.general.custom')), 'all', ['class' => 'form-control select2 box-size']) }}
<div id="available-permissions" class="hidden mt-20" style="width: 700px; height: 200px; overflow-x: hidden; overflow-y: scroll;"> <div id="available-permissions" class="hidden mt-20" style="width: 700px; height: 200px; overflow-x: hidden; overflow-y: scroll;">
<div class="row"> <div class="row">
......
...@@ -31,15 +31,10 @@ ...@@ -31,15 +31,10 @@
</div><!--form control--> </div><!--form control-->
<div class="form-group"> <div class="form-group">
{{ Form::label('associated-permissions', trans('validation.attributes.backend.access.roles.associated_permissions'), ['class' => 'col-lg-2 control-label']) }} {{ Form::label('associated_permissions', trans('validation.attributes.backend.access.roles.associated_permissions'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10"> <div class="col-lg-10">
@if ($role->id != 1) {{ Form::select('associated_permissions', ['all' => 'All', 'custom' => 'Custom'], $role->all ? 'all' : 'custom', ['class' => 'form-control select2 box-size']) }}
{{-- Administrator has to be set to all --}}
{{ Form::select('associated-permissions', ['all' => 'All', 'custom' => 'Custom'], $role->all ? 'all' : 'custom', ['class' => 'form-control select2 box-size']) }}
@else
<span class="label label-success">{{ trans('labels.general.all') }}</span>
@endif
<div id="available-permissions" class="hidden mt-20" style="width: 700px; height: 200px; overflow-x: hidden; overflow-y: scroll;"> <div id="available-permissions" class="hidden mt-20" style="width: 700px; height: 200px; overflow-x: hidden; overflow-y: scroll;">
<div class="row"> <div class="row">
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
@foreach($roles as $role) @foreach($roles as $role)
<div> <div>
<label for="role-{{$role->id}}" class="control control--radio"> <label for="role-{{$role->id}}" class="control control--radio">
<input type="radio" value="{{$role->id}}" name="assignees_roles[]" id="role-{{$role->id}}" class="get-role-for-permissions" /> &nbsp;&nbsp;{!! $role->name !!} <input type="radio" value="{{$role->id}}" name="assignees_roles[]" id="role-{{$role->id}}" class="get-role-for-permissions" {{ $role->id == 3 ? 'checked' : '' }} /> &nbsp;&nbsp;{!! $role->name !!}
<div class="control__indicator"></div> <div class="control__indicator"></div>
<a href="#" data-role="role_{{ $role->id }}" class="show-permissions small"> <a href="#" data-role="role_{{ $role->id }}" class="show-permissions small">
( (
...@@ -220,6 +220,7 @@ ...@@ -220,6 +220,7 @@
}); });
}); });
$("#role-3").click();
}); });
</script> </script>
@endsection @endsection
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@endsection @endsection
@section('content') @section('content')
{{ Form::open(['route' => 'admin.blogcategories.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-permission']) }} {{ Form::open(['route' => 'admin.blogCategories.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-permission']) }}
<div class="box box-info"> <div class="box box-info">
<div class="box-header with-border"> <div class="box-header with-border">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="form-group"> <div class="form-group">
@include("backend.blogcategories.form") @include("backend.blogcategories.form")
<div class="edit-form-btn"> <div class="edit-form-btn">
{{ link_to_route('admin.blogcategories.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }} {{ link_to_route('admin.blogCategories.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }} {{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@endsection @endsection
@section('content') @section('content')
{{ Form::model($blogcategory, ['route' => ['admin.blogcategories.update', $blogcategory], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role']) }} {{ Form::model($blogcategory, ['route' => ['admin.blogCategories.update', $blogcategory], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role']) }}
<div class="box box-info"> <div class="box box-info">
<div class="box-header with-border"> <div class="box-header with-border">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="form-group"> <div class="form-group">
@include("backend.blogcategories.form") @include("backend.blogcategories.form")
<div class="edit-form-btn"> <div class="edit-form-btn">
{{ link_to_route('admin.blogcategories.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }} {{ link_to_route('admin.blogCategories.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }} {{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
processing: true, processing: true,
serverSide: true, serverSide: true,
ajax: { ajax: {
url: '{{ route("admin.blogcategories.get") }}', url: '{{ route("admin.blogCategories.get") }}',
type: 'post' type: 'post'
}, },
columns: [ columns: [
......
<!--Action Button--> <!--Action Button-->
@if(Active::checkUriPattern('admin/blogcategories')) @if(Active::checkUriPattern('admin/blogCategories'))
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export <button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span> <span class="caret"></span>
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<span class="sr-only">Toggle Dropdown</span> <span class="sr-only">Toggle Dropdown</span>
</button> </button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.blogcategories.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogcategories.all')}}</a></li> <li><a href="{{route('admin.blogCategories.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogcategories.all')}}</a></li>
@permission('create-blog-category') @permission('create-blog-category')
<li><a href="{{route('admin.blogcategories.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogcategories.create')}}</a></li> <li><a href="{{route('admin.blogCategories.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogcategories.create')}}</a></li>
@endauth @endauth
</ul> </ul>
</div> </div>
\ No newline at end of file
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
{{ Form::label('featured_image', trans('validation.attributes.backend.blogs.image'), ['class' => 'col-lg-2 control-label required']) }} {{ Form::label('featured_image', trans('validation.attributes.backend.blogs.image'), ['class' => 'col-lg-2 control-label required']) }}
@if(!empty($blog->featured_image)) @if(!empty($blog->featured_image))
<div class="col-lg-1"> <div class="col-lg-1">
<img src="/img/backend/blog_images/{{$blog->featured_image}}" height="80" width="80"> <img src="{{ Storage::disk('public')->url('img/blog/' . $blog->featured_image) }}" height="80" width="80">
</div> </div>
<div class="col-lg-5"> <div class="col-lg-5">
<div class="custom-file-input"> <div class="custom-file-input">
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@endsection @endsection
@section('content') @section('content')
{{ Form::open(['route' => 'admin.blogtags.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-permission']) }} {{ Form::open(['route' => 'admin.blogTags.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-blogtags']) }}
<div class="box box-info"> <div class="box box-info">
<div class="box-header with-border"> <div class="box-header with-border">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="form-group"> <div class="form-group">
@include("backend.blogtags.form") @include("backend.blogtags.form")
<div class="edit-form-btn"> <div class="edit-form-btn">
{{ link_to_route('admin.blogtags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }} {{ link_to_route('admin.blogTags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }} {{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@endsection @endsection
@section('content') @section('content')
{{ Form::model($blogtag, ['route' => ['admin.blogtags.update', $blogtag], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role']) }} {{ Form::model($blogtag, ['route' => ['admin.blogTags.update', $blogtag], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-blogtags']) }}
<div class="box box-info"> <div class="box box-info">
<div class="box-header with-border"> <div class="box-header with-border">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="form-group"> <div class="form-group">
@include("backend.blogtags.form") @include("backend.blogtags.form")
<div class="edit-form-btn"> <div class="edit-form-btn">
{{ link_to_route('admin.blogtags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }} {{ link_to_route('admin.blogTags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }} {{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
processing: true, processing: true,
serverSide: true, serverSide: true,
ajax: { ajax: {
url: '{{ route("admin.blogtags.get") }}', url: '{{ route("admin.blogTags.get") }}',
type: 'post' type: 'post'
}, },
columns: [ columns: [
......
<!--Action Button--> <!--Action Button-->
@if(Active::checkUriPattern('admin/blogtags')) @if(Active::checkUriPattern('admin/blogTags'))
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export <button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span> <span class="caret"></span>
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<span class="sr-only">Toggle Dropdown</span> <span class="sr-only">Toggle Dropdown</span>
</button> </button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.blogtags.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogtags.all')}}</a></li> <li><a href="{{route('admin.blogTags.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogtags.all')}}</a></li>
@permission('create-blog-tag') @permission('create-blog-tag')
<li><a href="{{route('admin.blogtags.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogtags.create')}}</a></li> <li><a href="{{route('admin.blogTags.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogtags.create')}}</a></li>
@endauth @endauth
</ul> </ul>
</div> </div>
......
...@@ -90,15 +90,15 @@ ...@@ -90,15 +90,15 @@
<ul class="treeview-menu {{ active_class(Active::checkUriPattern('admin/blog*'), 'menu-open') }}" style="display: none; {{ active_class(Active::checkUriPattern('admin/blog*'), 'display: block;') }}"> <ul class="treeview-menu {{ active_class(Active::checkUriPattern('admin/blog*'), 'menu-open') }}" style="display: none; {{ active_class(Active::checkUriPattern('admin/blog*'), 'display: block;') }}">
@permission('view-blog-category') @permission('view-blog-category')
<li class="{{ active_class(Active::checkUriPattern('admin/blogcategories*')) }}"> <li class="{{ active_class(Active::checkUriPattern('admin/blogCategories*')) }}">
<a href="{{ route('admin.blogcategories.index') }}"> <a href="{{ route('admin.blogCategories.index') }}">
<span>{{ trans('menus.backend.blogcategories.management') }}</span> <span>{{ trans('menus.backend.blogcategories.management') }}</span>
</a> </a>
</li> </li>
@endauth @endauth
@permission('view-blog-tag') @permission('view-blog-tag')
<li class="{{ active_class(Active::checkUriPattern('admin/blogtags*')) }}"> <li class="{{ active_class(Active::checkUriPattern('admin/blogTags*')) }}">
<a href="{{ route('admin.blogtags.index') }}"> <a href="{{ route('admin.blogTags.index') }}">
<span>{{ trans('menus.backend.blogtags.management') }}</span> <span>{{ trans('menus.backend.blogtags.management') }}</span>
</a> </a>
</li> </li>
...@@ -111,6 +111,9 @@ ...@@ -111,6 +111,9 @@
</li> </li>
@endauth @endauth
</ul> </ul>
</li>
@endauth
@permission('view-faq') @permission('view-faq')
<li class="{{ active_class(Active::checkUriPattern('admin/faqs*')) }}"> <li class="{{ active_class(Active::checkUriPattern('admin/faqs*')) }}">
<a href="{{ route('admin.faqs.index')}}"> <a href="{{ route('admin.faqs.index')}}">
...@@ -119,8 +122,6 @@ ...@@ -119,8 +122,6 @@
</a> </a>
</li> </li>
@endauth @endauth
</li>
@endauth
<li class="{{ active_class(Active::checkUriPattern('admin/log-viewer*')) }} treeview"> <li class="{{ active_class(Active::checkUriPattern('admin/log-viewer*')) }} treeview">
<a href="#"> <a href="#">
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<th>{{ trans('labels.backend.pages.table.title') }}</th> <th>{{ trans('labels.backend.pages.table.title') }}</th>
<th>{{ trans('labels.backend.pages.table.status') }}</th> <th>{{ trans('labels.backend.pages.table.status') }}</th>
<th>{{ trans('labels.backend.pages.table.createdat') }}</th> <th>{{ trans('labels.backend.pages.table.createdat') }}</th>
<th>{{ trans('labels.backend.pages.table.updatedat') }}</th> <th>{{ trans('labels.backend.pages.table.createdby') }}</th>
<th>{{ trans('labels.general.actions') }}</th> <th>{{ trans('labels.general.actions') }}</th>
</tr> </tr>
</thead> </thead>
...@@ -77,10 +77,10 @@ ...@@ -77,10 +77,10 @@
{data: 'title', name: '{{config('module.pages.table')}}.title'}, {data: 'title', name: '{{config('module.pages.table')}}.title'},
{data: 'status', name: '{{config('module.pages.table')}}.status'}, {data: 'status', name: '{{config('module.pages.table')}}.status'},
{data: 'created_at', name: '{{config('module.pages.table')}}.created_at'}, {data: 'created_at', name: '{{config('module.pages.table')}}.created_at'},
{data: 'updated_at', name: '{{config('module.pages.table')}}.updated_at'}, {data: 'created_by', name: '{{config('access.users_table')}}.first_name'},
{data: 'actions', name: 'actions', searchable: false, sortable: false} {data: 'actions', name: 'actions', searchable: false, sortable: false}
], ],
order: [[3, "asc"]], order: [[1, "asc"]],
searchDelay: 500, searchDelay: 500,
dom: 'lBfrtip', dom: 'lBfrtip',
buttons: { buttons: {
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* Blogs Categories Management * Blogs Categories Management
*/ */
Route::group(['namespace' => 'BlogCategories'], function () { Route::group(['namespace' => 'BlogCategories'], function () {
Route::resource('blogcategories', 'BlogCategoriesController', ['except' => ['show']]); Route::resource('blogCategories', 'BlogCategoriesController', ['except' => ['show']]);
//For DataTables //For DataTables
Route::post('blogcategories/get', 'BlogCategoriesTableController') Route::post('blogCategories/get', 'BlogCategoriesTableController')
->name('blogcategories.get'); ->name('blogCategories.get');
}); });
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* Blogs Tags Management * Blogs Tags Management
*/ */
Route::group(['namespace' => 'BlogTags'], function () { Route::group(['namespace' => 'BlogTags'], function () {
Route::resource('blogtags', 'BlogTagsController', ['except' => ['show']]); Route::resource('blogTags', 'BlogTagsController', ['except' => ['show']]);
//For DataTables //For DataTables
Route::post('blogtags/get', 'BlogTagsTableController') Route::post('blogTags/get', 'BlogTagsTableController')
->name('blogtags.get'); ->name('blogTags.get');
}); });
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
Route::group(['namespace' => 'Settings'], function () { Route::group(['namespace' => 'Settings'], function () {
Route::resource('settings', 'SettingsController', ['except' => ['show', 'create', 'save', 'index', 'destroy']]); Route::resource('settings', 'SettingsController', ['except' => ['show', 'create', 'save', 'index', 'destroy']]);
Route::post('removeicon', 'SettingsController@removeIcon')->name('removeicon'); Route::post('removeicon/{setting}', 'SettingsLogoController@destroy')->name('removeIcon');
}); });
...@@ -2,11 +2,101 @@ ...@@ -2,11 +2,101 @@
namespace Tests; namespace Tests;
use App\Models\Access\Role\Role;
use App\Models\Access\User\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase; use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class BrowserKitTestCase extends BaseTestCase abstract class BrowserKitTestCase extends BaseTestCase
{ {
use CreatesApplication; use CreatesApplication,
RefreshDatabase;
public $baseUrl = 'http://localhost:8000'; /**
* @var
*/
public $baseUrl;
/**
* @var
*/
protected $admin;
/**
* @var
*/
protected $executive;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $adminRole;
/**
* @var
*/
protected $executiveRole;
/**
* @var
*/
protected $userRole;
public function setUp()
{
parent::setUp();
$this->baseUrl = config('app.url', 'http://localhost:8000');
// Set up the database
Artisan::call('migrate:refresh');
Artisan::call('db:seed');
/*
* Create class properties to be used in tests
*/
$this->admin = User::find(1);
$this->executive = User::find(2);
$this->user = User::find(3);
$this->adminRole = Role::find(1);
$this->executiveRole = Role::find(2);
$this->userRole = Role::find(3);
}
public function tearDown()
{
$this->beforeApplicationDestroyed(function () {
DB::disconnect();
});
parent::tearDown();
}
/**
* Check if User is logged in or not.
*
* @return bool true or false
*/
protected function assertLoggedIn()
{
$this->assertTrue(Auth::check());
}
/**
* Check if User is logged out or not.
*
* @return bool true or false
*/
protected function assertLoggedOut()
{
$this->assertFalse(Auth::check());
}
} }
<?php
namespace Tests\Feature\Api\V1;
use Illuminate\Support\Facades\Auth;
use Tests\TestCase;
class LoginTest extends TestCase
{
/** @test */
public function users_can_login_through_api()
{
$res = $this->json('POST', '/api/v1/auth/login', [
'email' => $this->user->email,
'password' => '1234',
])
->assertStatus(200)
->assertJsonStructure([
'message',
'token',
]);
}
}
<?php
namespace Tests\Feature\Auth;
use App\Events\Frontend\Auth\UserLoggedIn;
use App\Models\Access\User\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Tests\BrowserKitTestCase;
class LoginTest extends BrowserKitTestCase
{
/** @test */
public function login_page_loads_properly()
{
$this->visit('/login')
->see('Email')
->see('Password')
->see('Login')
->dontSee('You are logged in!');
}
/** @test */
public function login_fails_when_a_required_field_is_not_filled_in()
{
$this->visit('/login')
->type('', 'email')
->type('', 'password')
->press('Login')
->seePageIs('/login')
->see('The email field is required.')
->see('The password field is required.');
}
/** @test */
public function login_fails_when_password_is_incorrect()
{
$this->visit('/login')
->type('admin@admin.com', 'email')
->type('invalidpass', 'password')
->press('Login')
->seePageIs('/login')
->see('These credentials do not match our records.');
}
/** @test */
public function login_failure_with_wrong_inputs()
{
$this->visit('/login')
->type('wrongusername@wrongpassword.com', 'email')
->type('wrongpassword', 'password')
->press('Login')
->seePageIs('/login')
->see('These credentials do not match our records.');
}
/** @test */
public function unconfirmed_users_can_not_logIn()
{
Auth::logout();
config(['access.users.requires_approval' => false]);
// Create default user to test with
$unconfirmed = factory(User::class)->states('unconfirmed')->create();
$unconfirmed->attachRole(3); //User
$this->visit('/login')
->type($unconfirmed->email, 'email')
->type('secret', 'password')
->press('Login')
->seePageIs('/login')
->see('Your account is not confirmed.');
}
/** @test **/
public function inactive_users_can_not_login()
{
Auth::logout();
// Create default user to test with
$inactive = factory(User::class)->states('confirmed', 'inactive')->create();
$inactive->attachRole(3); //User
$this->visit('/login')
->type($inactive->email, 'email')
->type('secret', 'password')
->press('Login')
->seePageIs('/login')
->see('Your account has been deactivated.');
}
/** @test */
public function users_can_login()
{
// Make sure our events are fired
Event::fake();
Auth::logout();
//User Test
$this->visit('/login')
->type($this->user->email, 'email')
->type('1234', 'password')
->press('Login')
->see($this->user->name)
->seePageIs('/dashboard');
$this->assertLoggedIn();
Auth::logout();
//Admin Test
$this->visit('/login')
->type($this->admin->email, 'email')
->type('1234', 'password')
->press('Login')
->seePageIs('/admin/dashboard')
->see($this->admin->first_name)
->see('Access Management');
$this->assertLoggedIn();
Event::assertDispatched(UserLoggedIn::class);
}
}
<?php
namespace Tests\Feature\Auth;
use App\Events\Frontend\Auth\UserRegistered;
use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Tests\BrowserKitTestCase;
class RegistrationTest extends BrowserKitTestCase
{
/** @test */
public function registration_page_loads_properly()
{
$this->visit('/register')
->see('first_name')
->see('last_name')
->see('email')
->see('password')
->see('is_term_accept')
->see('Register');
}
/** @test */
public function registration_fails_when_a_required_field_is_not_filled_in()
{
$this->visit('/register')
->type('', 'first_name')
->type('', 'last_name')
->type('', 'email')
->type('', 'password')
->press('Register')
->seePageIs('/register')
->see('The first name field is required.')
->see('The last name field is required.')
->see('The email field is required.')
->see('The password field is required.')
->see('The is term accept field is required.');
}
/**
* Test the registration form
* Test it works with confirming email on or off, and that the confirm email notification is sent
* Note: Captcha is disabled by default in phpunit.xml.
*/
/** @test */
public function user_can_register()
{
// Make sure our events are fired
Event::fake();
config(['access.users.confirm_email' => false]);
config(['access.users.requires_approval' => false]);
$this->visit('/register')
->type('John', 'first_name')
->type('Doe', 'last_name')
->type('john.doe@example.com', 'email')
->type('Viral@1234', 'password')
->type('Viral@1234', 'password_confirmation')
->check('is_term_accept')
->press('Register')
->seePageIs('/')
->seeInDatabase(config('access.users_table'),
[
'email' => 'john.doe@example.com',
'first_name' => 'John',
'last_name' => 'Doe',
'confirmed' => 1,
]);
Event::assertDispatched(UserRegistered::class);
}
/**
* Test the registration form when account are set to be pending an approval
* ensure they are registered but not confirmed.
*/
/** @test */
public function registration_for_pending_approval()
{
Event::fake();
Notification::fake();
// Set registration to pending approval
config(['access.users.confirm_email' => false]);
config(['access.users.requires_approval' => true]);
$this->visit('/register')
->type('first name', 'first_name')
->type('last name', 'last_name')
->type('test@example.com', 'email')
->type('Viral@1234', 'password')
->type('Viral@1234', 'password_confirmation')
->check('is_term_accept')
->press('Register')
->see('Your account was successfully created and is pending approval. An e-mail will be sent when your account is approved.')
->see('Login')
->seePageIs('/')
->seeInDatabase(config('access.users_table'),
[
'email' => 'test@example.com',
'first_name' => 'first name',
'last_name' => 'last name',
'confirmed' => 0,
]);
// Get the user that was inserted into the database
$user = User::where('email', 'test@example.com')->first();
Notification::assertNotSentTo([$user], UserNeedsConfirmation::class);
Event::assertDispatched(UserRegistered::class);
}
}
<?php
namespace Tests\Feature\Auth;
use App\Notifications\Frontend\Auth\UserNeedsPasswordReset;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Notification;
use Tests\BrowserKitTestCase;
class ResetPasswordTest extends BrowserKitTestCase
{
/** @test */
public function forgot_password_page_loads_properly()
{
$this->visit('/password/reset')
->see('Email')
->see('Reset Password');
}
/** @test **/
public function forgot_password_fails_when_a_required_field_is_not_filled_in()
{
$this->visit('/password/reset')
->type('', 'email')
->press('Send Password Reset Link')
->seePageIs('/password/reset')
->see('The email field is required.');
}
/** @test **/
public function users_can_request_a_password_reset_link()
{
Notification::fake();
$this->visit('password/reset')
->type($this->user->email, 'email')
->press('Send Password Reset Link')
->seePageIs('password/reset')
->see('We have e-mailed your password reset link!')
->seeInDatabase('password_resets', ['email' => $this->user->email]);
Notification::assertSentTo(
[$this->user],
UserNeedsPasswordReset::class
);
}
/** @test **/
public function reset_password_fails_when_a_required_field_is_not_filled_in()
{
$token = $this->app->make('auth.password.broker')->createToken($this->user);
$this->visit('password/reset/'.$token)
->see($this->user->email)
->type('', 'password')
->type('', 'password_confirmation')
->press('Reset Password')
->see('The password field is required.');
}
/** @test **/
public function users_can_reset_password()
{
$token = $this->app->make('auth.password.broker')->createToken($this->user);
$this->visit('password/reset/'.$token)
->see($this->user->email)
->type('12345678', 'password')
->type('12345678', 'password_confirmation')
->press('Reset Password')
->see($this->user->first_name);
}
}
<?php
namespace Tests\Feature;
use Tests\BrowserKitTestCase;
class AuthTest extends BrowserKitTestCase
{
/** @test */
public function login_page_loads_properly()
{
$this->visit('/login')
->see('Email')
->see('Password')
->see('Login')
->dontSee('You are logged in!');
}
/** @test */
public function login_failure_without_inputs()
{
$this->visit('/login')
->press('Login')
->seePageIs('/login')
->see('The email field is required.')
->see('The password field is required.');
}
/** @test */
/*public function test_login_failure_with_wrong_inputs()
{
$this->visit("/login")
->type('wrongusername@wrongpassword.com', 'email')
->type('wrongpassword', 'password')
->press('Login')
->seePageIs('/login')
->see('These credentials do not match our records.');
}*/
/** @test */
public function users_can_login()
{
//$this->createUser();
$this->visit('/login')
->type('user@user.com', 'email')
->type('1234', 'password')
//->press('Login')
->seePageIs('/login');
}
}
<?php
namespace Tests\Feature\Backend;
use App\Events\Backend\Access\User\UserPasswordChanged;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class ChangePasswordTest extends TestCase
{
/** @test */
public function a_user_require_old_password_to_change_password()
{
$data = [];
$data['old_password'] = '12345';
$data['password'] = 'Viral@1234';
$data['password_confirmation'] = 'Viral@1234';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.access.user.change-password', $this->admin), $data)
->assertSessionHas(['flash_danger' => trans('exceptions.backend.access.users.change_mismatch')]);
}
/** @test */
/*public function a_user_require_strong_password_to_change_password()
{
$data = [];
$data['old_password'] = '1234';
$data['password'] = '12345678';
$data['password_confirmation'] = '12345678';
$this->withExceptionHandling()
->actingAs($this->executive)
->patch(route('admin.access.user.change-password', $this->executive), $data)
->assertSessionHas('The given data was invalid.');
}*/
/** @test */
public function a_user_can_change_password()
{
Event::fake();
$data = [];
$data['old_password'] = '1234';
$data['password'] = 'Viral@1234';
$data['password_confirmation'] = 'Viral@1234';
$this->actingAs($this->admin)
->patch(route('admin.access.user.change-password', $this->admin), $data)
->assertSessionHas(['flash_success' => trans('alerts.backend.users.updated_password')]);
Event::assertDispatched(UserPasswordChanged::class);
}
}
<?php
namespace Tests\Feature\Backend\History;
use Tests\BrowserKitTestCase;
/**
* Class HistoryLogTest.
*/
class HistoryLogTest extends BrowserKitTestCase
{
/** @test **/
public function history_log_by_type_name_function()
{
$this->actingAs($this->admin);
history()
->withType('User')
->withText(trans('history.backend.users.created').$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
$this->seeInDatabase('history',
[
'type_id' => 1,
'user_id' => $this->admin->id,
'entity_id' => $this->user->id,
'icon' => 'plus',
'class' => 'bg-green',
'text' => trans('history.backend.users.created').$this->user->name,
])
->visit('/admin/dashboard')
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
}
/** @test **/
public function history_log_By_TypeId_Function()
{
$this->actingAs($this->admin);
history()
->withType(1)
->withText(trans('history.backend.users.created').$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
$this->seeInDatabase('history',
[
'type_id' => 1,
'user_id' => $this->admin->id,
'entity_id' => $this->user->id,
'icon' => 'plus',
'class' => 'bg-green',
'text' => trans('history.backend.users.created').$this->user->name,
])
->visit('/admin/dashboard')
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
}
}
<?php
namespace Tests\Feature\Backend\History;
use App\Models\Access\User\User;
use Tests\BrowserKitTestCase;
/**
* Class HistoryRenderEntityTest.
*/
class HistoryRenderEntityTest extends BrowserKitTestCase
{
/** @test **/
public function users_can_see_history_of_entity()
{
$this->actingAs($this->admin);
$test_user = factory(User::class)->create();
history()
->withType('User')
->withText('trans("history.backend.users.created") '.$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
history()
->withType('User')
->withText('trans("history.backend.users.updated") '.$this->user->name)
->withEntity($this->user->id)
->withIcon('pencil')
->withClass('bg-blue')
->log();
history()
->withType('User')
->withText('trans("history.backend.users.deleted") '.$this->user->name)
->withEntity($this->user->id)
->withIcon('trash')
->withClass('bg-red')
->log();
history()
->withType('User')
->withText('trans("history.backend.roles.created") '.$test_user->name)
->withEntity($test_user->id)
->withIcon('plus')
->withClass('bg-red')
->log();
history()
->withType('User')
->withText('trans("history.backend.roles.updated") '.$test_user->name)
->withEntity($test_user->id)
->withIcon('pencil')
->withClass('bg-red')
->log();
history()
->withType('User')
->withText('trans("history.backend.roles.deleted") '.$test_user->name)
->withEntity($test_user->id)
->withIcon('trash')
->withClass('bg-red')
->log();
$this->visit('/admin/access/user/'.$this->user->id)
->see('<strong>'.$this->admin->name.'</strong> created user '.$this->user->name)
->see('<strong>'.$this->admin->name.'</strong> updated user '.$this->user->name)
->see('<strong>'.$this->admin->name.'</strong> deleted user '.$this->user->name)
->dontSee('<strong>'.$this->admin->name.'</strong> created user '.$test_user->name)
->dontSee('<strong>'.$this->admin->name.'</strong> updated user '.$test_user->name)
->dontSee('<strong>'.$this->admin->name.'</strong> deleted user '.$test_user->name);
}
}
<?php
namespace Tests\Feature\Backend\History;
use Tests\BrowserKitTestCase;
/**
* Class HistoryRenderTest.
*/
class HistoryRenderTest extends BrowserKitTestCase
{
/** @test **/
public function admin_users_can_see_history_on_dashboard()
{
$this->actingAs($this->admin);
history()
->withType('User')
->withText(trans('history.backend.users.created').$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
$this->visit('/admin/dashboard')
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
}
/** @test **/
public function admin_users_can_see_history_on_user_show_page()
{
$this->actingAs($this->admin);
history()
->withType('User')
->withText(trans('history.backend.users.created').$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
$this->visit('/admin/access/user/3')
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
}
}
<?php
namespace Tests\Feature\Backend;
use Tests\BrowserKitTestCase;
/**
* Class LogViewerRouteTest.
*/
class LogViewerRouteTest extends BrowserKitTestCase
{
/** @test **/
public function admin_users_can_see_logviewer_dashboard()
{
$this->actingAs($this->admin)
->visit('/admin/log-viewer')
->see('Log Viewer');
}
/** @test **/
public function admin_users_can_see_logviewer_list()
{
$this->actingAs($this->admin)
->visit('/admin/log-viewer/logs')
->see('Logs');
}
/** @test **/
public function admin_users_can_see_logviewer_single_date()
{
$this->actingAs($this->admin)
->visit('/admin/log-viewer/logs/'.date('Y-m-d'))
->see('Log ['.date('Y-m-d').']');
}
/** @test **/
public function admin_users_can_see_logviewer_single_date_type()
{
$this->actingAs($this->admin)
->visit('/admin/log-viewer/logs/'.date('Y-m-d').'/error')
->see('Log ['.date('Y-m-d').']');
}
}
<?php
namespace Tests\Feature\Backend;
use App\Models\BlogCategories\BlogCategory;
use Tests\TestCase;
class ManageBlogCategoriesTest extends TestCase
{
/** @test */
public function a_user_can_view_blog_categories_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogCategories.index'))
->assertViewIs('backend.blogcategories.index')
->assertSee(trans('labels.backend.blogcategories.management'))
->assertSee(trans('labels.backend.blogcategories.table.title'))
->assertSee(trans('labels.backend.blogcategories.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog_category()
{
$this->actingAs($this->admin);
$category = make(BlogCategory::class);
$this->post(route('admin.blogCategories.store'), $category->toArray());
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $category->name]);
}
/** @test */
public function a_blog_category_requires_a_name_while_creating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$category = make(BlogCategory::class, ['name' => '']);
$this->post(route('admin.blogCategories.store'), $category->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function a_blog_category_requires_a_name_while_updating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$category = create(BlogCategory::class);
$this->patch(route('admin.blogCategories.update', $category), ['name' => ''])
->assertSessionHasErrors('name');
}
/** @test */
public function a_user_can_update_a_blog_category()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class);
$this->patch(route('admin.blogCategories.update', $category), ['name' => 'New Category']);
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => 'New Category', 'id' => $category->id]);
}
/** @test */
public function a_user_can_delete_a_blog_category()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class);
$this->delete(route('admin.blogCategories.destroy', $category));
$this->assertDatabaseMissing(config('module.blog_categories.table'), ['name' => $category->name, 'id' => $category->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Models\BlogTags\BlogTag;
use Tests\TestCase;
class ManageBlogTagsTest extends TestCase
{
/** @test */
public function a_user_can_view_blog_tags_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogTags.index'))
->assertViewIs('backend.blogtags.index')
->assertSee(trans('labels.backend.blogtags.management'))
->assertSee(trans('labels.backend.blogtags.table.title'))
->assertSee(trans('labels.backend.blogtags.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog_tag()
{
$this->actingAs($this->admin);
$tag = make(BlogTag::class);
$this->post(route('admin.blogTags.store'), $tag->toArray());
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => $tag->name]);
}
/** @test */
public function a_blog_tag_requires_a_name_while_creating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$tag = make(BlogTag::class, ['name' => '']);
$this->post(route('admin.blogTags.store'), $tag->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function a_blog_tag_requires_a_name_while_updating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$tag = create(BlogTag::class);
$this->patch(route('admin.blogTags.update', $tag), ['name' => ''])
->assertSessionHasErrors('name');
}
/** @test */
public function a_user_can_update_a_blog_tag()
{
$this->actingAs($this->admin);
$tag = create(BlogTag::class);
$this->patch(route('admin.blogTags.update', $tag), ['name' => 'New Tag']);
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => 'New Tag', 'id' => $tag->id]);
}
/** @test */
public function a_user_can_delete_a_blog_tag()
{
$this->actingAs($this->admin);
$tag = create(BlogTag::class);
$this->delete(route('admin.blogTags.destroy', $tag));
$this->assertDatabaseMissing(config('module.blog_tags.table'), ['name' => $tag->name, 'id' => $tag->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Models\Blogs\Blog;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class ManageBlogsTest extends TestCase
{
use WithFaker;
protected $blog;
protected $categories;
protected $tags;
public function setUp()
{
parent::setUp();
$this->actingAs($this->admin);
$this->blog = create(Blog::class);
$this->categories = [$this->faker->word, $this->faker->word];
$this->tags = [$this->faker->word, $this->faker->word];
}
/** @test */
public function a_user_can_view_blogs_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogs.index'))
->assertViewIs('backend.blogs.index')
->assertSee(trans('labels.backend.blogs.management'))
->assertSee(trans('labels.backend.blogs.table.title'))
->assertSee(trans('labels.backend.blogs.table.publish'))
->assertSee(trans('labels.backend.blogs.table.createdby'))
->assertSee(trans('labels.backend.blogs.table.createdat'))
->assertSee(trans('labels.backend.blogs.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog()
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags,
]);
$this->post(route('admin.blogs.store'), $blog->toArray());
$this->assertDatabaseHas(config('module.blogs.table'), ['name' => $blog->name, 'status' => $blog->status]);
//Assert Tags have been saved
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => $this->tags[0]]);
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => $this->tags[1]]);
//Assert Categories have been saved
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $this->categories[0]]);
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $this->categories[1]]);
}
public function makeBlog($overrides = [])
{
$this->withExceptionHandling();
$blog = make(Blog::class, $overrides);
return $blog;
}
/** @test */
public function it_requires_name_while_creating()
{
$blog = $this->makeBlog(['name' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function it_requires_content_while_creating()
{
$blog = $this->makeBlog(['content' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('content');
}
/** @test */
public function it_requires_featured_image_while_creating()
{
$blog = $this->makeBlog(['featured_image' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('featured_image');
}
/** @test */
public function it_requires_categories_while_creating()
{
$blog = $this->makeBlog(['categories' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('categories');
}
/** @test */
public function it_requires_tags_while_creating()
{
$blog = $this->makeBlog(['tags' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('tags');
}
/** @test */
public function it_can_store_featured_image()
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags,
]);
$this->post(route('admin.blogs.store'), $blog->toArray());
$stored_blog = Blog::find(2);
Storage::disk('public')->assertExists('img/blog/'.$stored_blog->featured_image);
}
/** @test */
public function it_requires_name_while_updating()
{
$this->withExceptionHandling();
$this->blog->name = '';
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function it_requires_content_while_updating()
{
$this->withExceptionHandling();
$this->blog->content = '';
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('content');
}
/** @test */
public function it_requires_categories_while_updating()
{
$this->withExceptionHandling();
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('categories');
}
/** @test */
public function it_requires_tags_while_updating()
{
$this->withExceptionHandling();
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('tags');
}
/** @test */
public function a_user_can_update_blog()
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'name' => 'Changed Name',
'categories' => $this->categories,
'tags' => $this->tags,
]);
$this->patch(route('admin.blogs.update', $this->blog), $blog->toArray());
$this->assertDatabaseHas(config('module.blogs.table'), ['id' => $this->blog->id, 'name' => 'Changed Name']);
}
/** @test */
public function a_user_can_delete_a_blog()
{
$this->delete(route('admin.blogs.destroy', $this->blog));
$this->assertDatabaseMissing(config('module.blogs.table'), ['id' => $this->blog->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Models\Faqs\Faq;
use Tests\TestCase;
class ManageFaqsTest extends TestCase
{
/** @test */
public function a_user_can_view_faqs_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.faqs.index'))
->assertViewIs('backend.faqs.index')
->assertSee(trans('labels.backend.faqs.management'))
->assertSee(trans('labels.backend.faqs.table.question'))
->assertSee(trans('labels.backend.faqs.table.answer'))
->assertSee(trans('labels.backend.faqs.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_faq()
{
$faq = make(Faq::class);
$this->actingAs($this->admin)
->post(route('admin.faqs.store'), $faq->toArray());
$this->assertDatabaseHas(config('module.faqs.table'), ['question' => $faq->question, 'answer' => $faq->answer]);
}
/** @test */
public function it_requires_question_while_creating()
{
$faq = make(Faq::class, ['question' => '']);
$this->actingAs($this->admin)
->withExceptionHandling()
->post(route('admin.faqs.store'), $faq->toArray())
->assertSessionHasErrors('question');
}
/** @test */
public function it_requires_answer_while_creating()
{
$faq = make(Faq::class, ['answer' => '']);
$this->actingAs($this->admin)
->withExceptionHandling()
->post(route('admin.faqs.store'), $faq->toArray())
->assertSessionHasErrors('answer');
}
/** @test */
public function it_requires_question_while_updating()
{
$faq = create(Faq::class);
$this->actingAs($this->admin)
->withExceptionHandling()
->patch(route('admin.faqs.update', $faq), ['question' => '', 'answer' => $faq->answer])
->assertSessionHasErrors('question');
}
/** @test */
public function it_requires_answer_while_updating()
{
$faq = create(Faq::class);
$this->actingAs($this->admin)
->withExceptionHandling()
->patch(route('admin.faqs.update', $faq), ['question' => $faq->question, 'answer' => ''])
->assertSessionHasErrors('answer');
}
/** @test */
public function a_user_can_update_faq()
{
$faq = create(Faq::class);
$changed_question = 'What is Life?';
$changed_answer = $faq->answer;
$this->actingAs($this->admin)
->patch(route('admin.faqs.update', $faq), ['question' => $changed_question, 'answer' => $changed_answer]);
$this->assertDatabaseHas(config('module.faqs.table'), ['id' => $faq->id, 'question' => $changed_question, 'answer' => $changed_answer]);
}
/** @test */
public function a_user_can_delete_faq()
{
$faq = create(Faq::class);
$this->actingAs($this->admin)
->delete(route('admin.faqs.destroy', $faq));
$this->assertDatabaseMissing(config('module.faqs.table'), ['id' => $faq->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Models\Page\Page;
use Tests\TestCase;
class ManagePagesTest extends TestCase
{
/** @test */
public function a_user_can_view_pages()
{
$this->actingAs($this->admin)
->get(route('admin.pages.index'))
->assertSee(trans('labels.backend.pages.management'))
->assertSee(trans('labels.backend.pages.table.title'))
->assertSee(trans('labels.backend.pages.table.status'))
->assertSee($this->admin->name);
}
/** @test */
public function test_create_and_edit_page_has_all_fields()
{
$this->actingAs($this->admin)
->get(route('admin.pages.create'))
->assertSee(trans('validation.attributes.backend.pages.title'))
->assertSee(trans('validation.attributes.backend.pages.description'))
->assertSee(trans('validation.attributes.backend.pages.cannonical_link'))
->assertSee(trans('validation.attributes.backend.pages.seo_title'))
->assertSee(trans('validation.attributes.backend.pages.seo_keyword'))
->assertSee(trans('validation.attributes.backend.pages.seo_description'))
->assertSee(trans('validation.attributes.backend.pages.is_active'));
$page = create(Page::class);
$this->actingAs($this->admin)
->get(route('admin.pages.edit', $page))
->assertSee(trans('validation.attributes.backend.pages.title'))
->assertSee(trans('validation.attributes.backend.pages.description'))
->assertSee(trans('validation.attributes.backend.pages.cannonical_link'))
->assertSee(trans('validation.attributes.backend.pages.seo_title'))
->assertSee(trans('validation.attributes.backend.pages.seo_keyword'))
->assertSee(trans('validation.attributes.backend.pages.seo_description'))
->assertSee(trans('validation.attributes.backend.pages.is_active'));
}
/** @test */
public function a_user_can_create_page()
{
$page = make(Page::class);
$this->actingAs($this->admin)
->post(route('admin.pages.store'), $page->toArray())
->assertRedirect(route('admin.pages.index'));
$this->assertDatabaseHas('pages', ['title' => $page->title, 'description' => $page->description]);
}
/** @test */
public function it_requires_title_on_create()
{
$page = make(Page::class, ['title' => '']);
$this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.pages.store'), $page->toArray())
->assertSessionHasErrors('title');
}
/** @test */
public function it_requires_description_while_create()
{
$page = make(Page::class, ['description' => '']);
$this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.pages.store'), $page->toArray())
->assertSessionHasErrors('description');
}
/** @test */
public function a_user_can_update_page()
{
$page = create(Page::class);
$title = 'Changed title';
$slug = str_slug($title);
$description = 'Changed Description';
$this->actingAs($this->admin)
->patch(route('admin.pages.update', $page), ['title' => $title, 'description' => $description]);
$this->assertDatabaseHas('pages', ['id' => $page->id, 'title' => $title, 'page_slug' => $slug, 'description' => $description]);
}
/** @test */
public function it_requires_title_on_update()
{
$page = create(Page::class);
$page1 = $page->toArray();
$page1['title'] = '';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.pages.update', $page), $page1)
->assertSessionHasErrors('title');
}
/** @test */
public function it_requires_description_while_update()
{
$page = create(Page::class);
$page1 = $page->toArray();
$page1['description'] = '';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.pages.update', $page), $page1)
->assertSessionHasErrors('description');
}
/** @test */
public function a_user_can_delete_a_page()
{
$this->actingAs($this->admin);
$page = create(Page::class);
$this->delete(route('admin.pages.destroy', $page));
$this->assertDatabaseMissing(config('module.pages.table'), ['name' => $page->name, 'id' => $page->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Events\Backend\Access\Permission\PermissionCreated;
use App\Events\Backend\Access\Permission\PermissionDeleted;
use App\Events\Backend\Access\Permission\PermissionUpdated;
use App\Models\Access\Permission\Permission;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class ManagePermissionsTest extends TestCase
{
/** @test */
public function a_user_can_view_permissions()
{
$this->actingAs($this->admin)
->get(route('admin.access.permission.index'))
->assertViewIs('backend.access.permissions.index')
->assertSee(trans('labels.backend.access.permissions.management'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_permission_requires_a_name()
{
$permission = make(Permission::class, ['name' => null])->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.permission.store'), $permission)
->assertSessionHasErrors('name');
}
/** @test */
public function a_permission_requires_a_display_name()
{
$permission = make(Permission::class, ['display_name' => null])->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.permission.store'), $permission)
->assertSessionHasErrors('display_name');
}
/** @test */
public function a_user_can_create_new_permission()
{
// Make sure our events are fired
Event::fake();
$permission = make(Permission::class, ['name' => 'test permission'])->toArray();
$this->actingAs($this->admin)
->post(route('admin.access.permission.store'), $permission)
->assertRedirect(route('admin.access.permission.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.permissions.created')]);
$this->assertDatabaseHas(config('access.permissions_table'), [
'name' => $permission['name'],
]);
Event::assertDispatched(PermissionCreated::class);
}
/** @test */
public function it_fails_for_validation_on_update_permission()
{
$permission = create(Permission::class);
$data = $permission->toArray();
$data['name'] = '';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.access.permission.update', $permission), $data)
->assertSessionHasErrors(['name']);
}
/** @test */
public function a_user_can_update_permission()
{
Event::fake();
$permission = create(Permission::class);
$data = $permission->toArray();
$data['name'] = 'Updated Permission Name';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.access.permission.update', $permission), $data)
->assertRedirect(route('admin.access.permission.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.permissions.updated')]);
$this->assertDatabaseHas(config('access.permissions_table'), [
'name' => $data['name'],
]);
Event::assertDispatched(PermissionUpdated::class);
}
/** @test */
public function a_user_can_delete_a_permission()
{
Event::fake();
$permission = create(Permission::class);
$this->actingAs($this->admin)
->delete(route('admin.access.permission.destroy', $permission))
->assertStatus(302)
->assertSessionHas(['flash_success' => trans('alerts.backend.permissions.deleted')]);
/*$this->assertDatabaseMissing('permissions', [
'name' => $permission->name, 'id' => $permission->id
]);*/
Event::assertDispatched(PermissionDeleted::class);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Events\Backend\Access\Role\RoleCreated;
use App\Events\Backend\Access\Role\RoleDeleted;
use App\Events\Backend\Access\Role\RoleUpdated;
use App\Exceptions\GeneralException;
use App\Models\Access\Permission\Permission;
use App\Models\Access\Role\Role;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class ManageRolesTest extends TestCase
{
/** @test */
public function a_user_can_view_roles()
{
$this->actingAs($this->admin)
->get(route('admin.access.role.index'))
->assertViewIs('backend.access.roles.index')
->assertSee(trans('labels.backend.access.roles.management'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_role_requires_a_name()
{
$role = make(Role::class, ['name' => null])->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.role.store'), $role)
->assertSessionHasErrors('name');
}
/** @test */
public function a_role_requires_a_permission_if_associated_permissions_is_not_set_to_all()
{
$role = make(Role::class)->toArray();
$role['associated_permissions'] = 'custom';
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.role.store'), $role)
->assertSessionHasErrors('permissions');
}
/** @test */
/*public function a_role_can_not_create_if_name_is_already_exists()
{
$role = make(Role::class, ['name' => $this->adminRole->name])->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.role.store'), $role);
$this->assertSessionHas(['flash_danger' => trans('exceptions.backend.access.roles.already_exists')]);
$this->expectException(GeneralException::class);
}*/
/** @test */
public function a_user_can_create_new_role()
{
// Make sure our events are fired
Event::fake();
$role = make(Role::class, ['name' => 'test Role'])->toArray();
$role['associated_permissions'] = 'all';
$this->actingAs($this->admin)
->post(route('admin.access.role.store'), $role)
->assertRedirect(route('admin.access.role.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.roles.created')]);
$this->assertDatabaseHas(config('access.roles_table'), [
'name' => $role['name'],
]);
Event::assertDispatched(RoleCreated::class);
}
/** @test */
public function a_user_can_create_new_role_with_permissions()
{
// Make sure our events are fired
Event::fake();
$role = make(Role::class, ['name' => 'test Role'])->toArray();
$permission = create(Permission::class);
$role['associated_permissions'] = 'custom';
$role['permissions'] = [$permission->id];
$this->actingAs($this->admin)
->post(route('admin.access.role.store'), $role)
->assertRedirect(route('admin.access.role.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.roles.created')]);
$this->assertDatabaseHas(config('access.roles_table'), [
'name' => $role['name'],
]);
$this->assertDatabaseHas(config('access.permissions_table'), ['name' => $permission->name]);
$this->assertDatabaseHas(config('access.permission_role_table'), ['permission_id' => $permission->id]);
Event::assertDispatched(RoleCreated::class);
}
/** @test */
public function it_fails_for_validation_on_update_role()
{
$role = create(Role::class);
$data = $role->toArray();
$data['name'] = '';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.access.role.update', $role), $data)
->assertSessionHasErrors(['name']);
}
/** @test */
public function a_user_can_update_role()
{
Event::fake();
$role = create(Role::class);
$permission = create(Permission::class);
$data = $role->toArray();
$data['associated_permissions'] = 'custom';
$data['permissions'] = [$permission->id];
$data['name'] = 'Updated Role Name';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.access.role.update', $role), $data)
->assertRedirect(route('admin.access.role.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.roles.updated')]);
$this->assertDatabaseHas(config('access.roles_table'), [
'name' => $data['name'],
]);
$this->assertDatabaseHas(config('access.permissions_table'), ['name' => $permission->name]);
$this->assertDatabaseHas(config('access.permission_role_table'), ['permission_id' => $permission->id]);
Event::assertDispatched(RoleUpdated::class);
}
/** @test */
public function a_user_can_delete_a_role()
{
Event::fake();
$role = create(Role::class);
$this->actingAs($this->admin)
->delete(route('admin.access.role.destroy', $role))
->assertStatus(302)
->assertSessionHas(['flash_success' => trans('alerts.backend.roles.deleted')]);
/*$this->assertDatabaseMissing(config('access.roles_table'), [
'name' => $role->name,
'id' => $role->id
]);*/
Event::assertDispatched(RoleDeleted::class);
}
}
<?php
namespace Tests\Feature\Backend;
use App\Models\Settings\Setting;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class ManageSettingsTest extends TestCase
{
protected $setting;
public function setUp()
{
parent::setUp();
$this->setting = Setting::find(1);
$this->actingAs($this->admin);
}
/** @test */
public function setting_page_shows_different_tabs()
{
$this->get(route('admin.settings.edit', $this->setting))
->assertSee(__('labels.backend.settings.seo'))
->assertSee(__('labels.backend.settings.companydetails'))
->assertSee(__('labels.backend.settings.mail'))
->assertSee(__('labels.backend.settings.footer'))
->assertSee(__('labels.backend.settings.terms'))
->assertSee(__('labels.backend.settings.google'));
}
/** @test */
public function it_can_update_a_valid_site_logo()
{
$this->patch(route('admin.settings.update', $this->setting), [
'logo' => UploadedFile::fake()->image('logo.jpg', 226, 48),
]);
Storage::disk('public')->assertExists('img/logo/'.$this->setting->logo);
}
/** @test */
public function it_throws_error_for_valid_site_logo()
{
$this->withExceptionHandling();
$this->patch(route('admin.settings.update', $this->setting), [
'logo' => UploadedFile::fake()->image('logo.jpg', 200, 500),
])
->assertSessionHasErrors('logo');
}
/** @test */
public function it_can_update_site_favicon()
{
$this->patch(route('admin.settings.update', $this->setting), [
'favicon' => UploadedFile::fake()->image('favicon.jpg', 16, 16),
]);
Storage::disk('public')->assertExists('img/favicon/'.$this->setting->favicon);
}
/** @test */
public function it_throws_error_for_valid_site_favicon()
{
$this->withExceptionHandling();
$this->patch(route('admin.settings.update', $this->setting), [
'favicon' => UploadedFile::fake()->image('favicon.jpg', 200, 500),
])
->assertSessionHasErrors('favicon');
}
}
This diff is collapsed.
<?php
namespace Tests\Feature;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$response = $this->get('/');
$response->assertSee('Laravel AdminPanel');
}
}
<?php
namespace Tests\Feature\Frontend;
use App\Events\Frontend\Auth\UserLoggedOut;
use Illuminate\Support\Facades\Event;
use Tests\BrowserKitTestCase;
/**
* Class LoggedInRouteTest.
*/
class LoggedInRouteTest extends BrowserKitTestCase
{
/**
* Test the homepage works and the dashboard button appears.
*/
public function testHomePageLoggedIn()
{
$this->actingAs($this->user)->visit('/')->see('Dashboard')->see($this->user->name)->dontSee('Administration');
}
/**
* Test the dashboard page works and displays the users information.
*/
/** @test */
public function dashboard_page_loads_properly()
{
$this->actingAs($this->user)
->visit('/dashboard')
->see($this->user->email)
->see('Joined')
->dontSee('Administration');
}
/**
* Test the account page works and displays the users information.
*/
/** @test */
public function account_page_loads_properly()
{
$this->actingAs($this->user)
->visit('/account')
->see('My Account')
->see('Profile')
->see('Update Information')
->see('Change Password')
->dontSee('Administration');
}
/** @test */
public function users_can_logout()
{
// Make sure our events are fired
Event::fake();
$this->actingAs($this->user)->visit('/logout')->see('Login')->see('Register');
Event::assertDispatched(UserLoggedOut::class);
}
}
<?php
namespace Tests\Feature\Frontend;
use App\Events\Frontend\Auth\UserConfirmed;
use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Tests\BrowserKitTestCase;
/**
* Class LoggedOutRouteTest.
*/
class LoggedOutRouteTest extends BrowserKitTestCase
{
/**
* User Logged Out Frontend.
*/
/** @test */
public function test_homePage()
{
$this->visit('/')->assertResponseOk();
}
/** @test */
public function test_macroPage()
{
$this->visit('/macros')->see('Macro Examples');
}
/** @test */
public function testLoginPage()
{
$this->visit('/login')->see('Login');
}
/** @test */
public function testRegisterPage()
{
$this->visit('/register')->see('Register');
}
/** @test */
public function testForgotPasswordPage()
{
$this->visit('password/reset')->see('Reset Password');
}
/** @test */
public function testDashboardPageLoggedOut()
{
$this->visit('/dashboard')->seePageIs('/login');
}
/** @test */
public function testAccountPageLoggedOut()
{
$this->visit('/account')->seePageIs('/login');
}
/**
* Create an unconfirmed user and assure the user gets
* confirmed when hitting the confirmation route.
*/
/** @test */
public function confirm_account_route()
{
Event::fake();
// Create default user to test with
$unconfirmed = factory(User::class)->states('unconfirmed')->create();
$unconfirmed->attachRole(3); //User
$this->visit('/account/confirm/'.$unconfirmed->confirmation_code)
->seePageIs('/login')
->see('Your account has been successfully confirmed!')
->seeInDatabase(config('access.users_table'), ['email' => $unconfirmed->email, 'confirmed' => 1]);
Event::assertDispatched(UserConfirmed::class);
}
/**
* Assure the user gets resent a confirmation email
* after hitting the resend confirmation route.
*/
/** @test */
public function resend_confirm_account_route()
{
Notification::fake();
$this->visit('/account/confirm/resend/'.$this->user->id)
->seePageIs('/login')
->see('A new confirmation e-mail has been sent to the address on file.');
Notification::assertSentTo(
[$this->user],
UserNeedsConfirmation::class
);
}
/** @test */
public function test_404Page()
{
$response = $this->call('GET', '7g48hwbfw9eufj');
$this->assertEquals(404, $response->getStatusCode());
$this->assertContains('Page Not Found', $response->getContent());
}
}
This diff is collapsed.
<?php
namespace Tests\Unit;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment