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
DB_USERNAME=homestead
DB_PASSWORD=secret
# Access
ENABLE_REGISTRATION=true
REQUIRES_APPROVAL=false
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
......
......@@ -17,6 +17,25 @@ function generateUuid()
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.
*/
......
......@@ -57,49 +57,49 @@ class BlogCategoriesController extends Controller
$this->blogcategory->create($request->all());
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->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
*
* @return mixed
*/
public function edit(BlogCategory $blogcategory, EditBlogCategoriesRequest $request)
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{
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
*
* @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()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->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
*
* @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()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
}
}
......@@ -60,49 +60,49 @@ class BlogTagsController extends Controller
$this->blogtag->create($request->except('token'));
return redirect()
->route('admin.blogtags.index')
->route('admin.blogTags.index')
->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
*
* @return mixed
*/
public function edit(BlogTag $blogtag, EditBlogTagsRequest $request)
public function edit(BlogTag $blogTag, EditBlogTagsRequest $request)
{
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
*
* @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()
->route('admin.blogtags.index')
->route('admin.blogTags.index')
->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
*
* @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()
->route('admin.blogtags.index')
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.deleted'));
}
}
......@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Pages;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Pages\ManagePageRequest;
use App\Repositories\Backend\Pages\PagesRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
......@@ -32,17 +31,17 @@ class PagesTableController extends Controller
{
return Datatables::of($this->pages->getForDataTable())
->escapeColumns(['title'])
->addColumn('status', function ($pages) {
return $pages->status_label;
->addColumn('status', function ($page) {
return $page->status_label;
})
->addColumn('created_at', function ($pages) {
return Carbon::parse($pages->created_at)->toDateString();
->addColumn('created_at', function ($page) {
return $page->created_at->toDateString();
})
->addColumn('updated_at', function ($pages) {
return Carbon::parse($pages->updated_at)->toDateString();
->addColumn('created_by', function ($page) {
return $page->created_by;
})
->addColumn('actions', function ($pages) {
return $pages->action_buttons;
->addColumn('actions', function ($page) {
return $page->action_buttons;
})
->make(true);
}
......
......@@ -7,7 +7,6 @@ use App\Http\Requests\Backend\Settings\ManageSettingsRequest;
use App\Http\Requests\Backend\Settings\UpdateSettingsRequest;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/**
* Class SettingsController.
......@@ -50,22 +49,4 @@ class SettingsController extends Controller
->route('admin.settings.edit', $setting->id)
->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
*/
public function register(RegisterRequest $request)
{
if (config('access.users.confirm_email')) {
/*if (config('access.users.confirm_email')) {
$user = $this->user->create($request->all());
event(new UserRegistered($user));
......@@ -59,6 +59,22 @@ class RegisterController extends Controller
access()->login($this->user->create($request->all()));
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());
}
}
......
......@@ -50,9 +50,20 @@ class ResetPasswordController extends Controller
*/
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')
->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
'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
*/
public function rules()
{
$permissions = '';
if ($this->associated_permissions != 'all') {
$permissions = 'required';
}
return [
'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
*/
public function rules()
{
$permissions = '';
if ($this->associated_permissions != 'all') {
$permissions = 'required';
}
return [
'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
* @param $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);
......@@ -39,7 +47,7 @@ class UserEventListener
'email_template_type' => 1,
];
createNotification('', 1, 2, $options);
}
}*/
/**
* @param $event
......
......@@ -213,9 +213,9 @@ trait UserAttribute
/**
* @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
public function getActionButtonsAttribute()
{
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
......
......@@ -13,8 +13,8 @@ trait BlogCategoryAttribute
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogcategories.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogcategories.destroy').'
'.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogCategories.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogCategories.destroy').'
</div>';
}
......
......@@ -12,8 +12,8 @@ trait BlogCategoryRelationship
/**
* 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
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogtags.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogtags.destroy').'
'.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogTags.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogTags.destroy').'
</div>';
}
......
......@@ -12,8 +12,8 @@ trait BlogTagRelationship
/**
* 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
/**
* 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;
use App\Models\BaseModel;
use App\Models\ModelTrait;
use App\Models\Page\Traits\Attribute\PageAttribute;
use App\Models\Page\Traits\PageRelationship;
use Illuminate\Database\Eloquent\SoftDeletes;
class Page extends BaseModel
{
use ModelTrait,
SoftDeletes,
PageRelationship,
PageAttribute {
// PageAttribute::getEditButtonAttribute insteadof ModelTrait;
}
......@@ -29,6 +31,17 @@ class Page extends BaseModel
*/
protected $guarded = ['id'];
/**
* The default values for attributes.
*
* @var array
*/
protected $attributes = [
'created_by' => 1,
];
protected $with = ['owner'];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
......
......@@ -13,8 +13,8 @@ trait PageAttribute
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-cms-pages', 'admin.pages.edit').'
'.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.pages.destroy').'
'.$this->getEditButtonAttribute('edit-page', 'admin.pages.edit').'
'.$this->getDeleteButtonAttribute('delete-page', 'admin.pages.destroy').'
</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
}
//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'])) {
$input['permissions'] = [];
......@@ -133,7 +133,7 @@ class RoleRepository extends BaseRepository
if ($role->id == 1) {
$all = true;
} else {
$all = $input['associated-permissions'] == 'all' ? true : false;
$all = $input['associated_permissions'] == 'all' ? true : false;
}
if (!isset($input['permissions'])) {
......@@ -190,13 +190,13 @@ class RoleRepository extends BaseRepository
}
/**
* @param Model $role
* @param Role $role
*
* @throws GeneralException
*
* @return bool
*/
public function delete(Model $role)
public function delete(Role $role)
{
//Would be stupid to delete the administrator role
if ($role->id == 1) { //id is 1 because of the seeder
......
......@@ -97,9 +97,6 @@ class UserRepository extends BaseRepository
$user = $this->createUserStub($data);
DB::transaction(function () use ($user, $data, $roles, $permissions) {
// Set email type 2
$email_type = 2;
if ($user->save()) {
//User Created, Validate Roles
......@@ -120,18 +117,6 @@ class UserRepository extends BaseRepository
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;
}
......@@ -175,28 +160,23 @@ class UserRepository extends BaseRepository
}
/**
* @param Model $user
* Change Password.
*
* @param $user
* @param $input
*
* @throws GeneralException
*
* @return bool
*/
public function updatePassword(Model $user, $input)
public function updatePassword($user, $input)
{
$user = $this->find(access()->id());
if (Hash::check($input['old_password'], $user->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));
return true;
......@@ -215,7 +195,7 @@ class UserRepository extends BaseRepository
*
* @return bool
*/
public function delete(Model $user)
public function delete($user)
{
if (access()->id() == $user->id) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_self'));
......@@ -231,11 +211,11 @@ class UserRepository extends BaseRepository
}
/**
* @param Model $user
* @param $user
*
* @throws GeneralException
*/
public function forceDelete(Model $user)
public function forceDelete($user)
{
if (is_null($user->deleted_at)) {
throw new GeneralException(trans('exceptions.backend.access.users.delete_first'));
......@@ -253,13 +233,13 @@ class UserRepository extends BaseRepository
}
/**
* @param Model $user
* @param $user
*
* @throws GeneralException
*
* @return bool
*/
public function restore(Model $user)
public function restore($user)
{
if (is_null($user->deleted_at)) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_restore'));
......@@ -275,14 +255,14 @@ class UserRepository extends BaseRepository
}
/**
* @param Model $user
* @param $user
* @param $status
*
* @throws GeneralException
*
* @return bool
*/
public function mark(Model $user, $status)
public function mark($user, $status)
{
if (access()->id() == $user->id && $status == 0) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self'));
......@@ -301,13 +281,6 @@ class UserRepository extends BaseRepository
}
if ($user->save()) {
// Send email to the user
$options = [
'data' => $user,
'email_template_type' => 3,
];
createNotification('', $user->id, 2, $options);
return true;
}
......
......@@ -6,7 +6,6 @@ use App\Events\Backend\Blogs\BlogCreated;
use App\Events\Backend\Blogs\BlogDeleted;
use App\Events\Backend\Blogs\BlogUpdated;
use App\Exceptions\GeneralException;
use App\Http\Utilities\FileUploads;
use App\Models\BlogCategories\BlogCategory;
use App\Models\BlogMapCategories\BlogMapCategory;
use App\Models\BlogMapTags\BlogMapTag;
......@@ -15,6 +14,7 @@ use App\Models\BlogTags\BlogTag;
use App\Repositories\BaseRepository;
use Carbon\Carbon;
use DB;
use Illuminate\Support\Facades\Storage;
/**
* Class BlogsRepository.
......@@ -26,6 +26,21 @@ class BlogsRepository extends BaseRepository
*/
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
*/
......@@ -132,7 +147,7 @@ class BlogsRepository extends BaseRepository
/**
* Creating Tags.
*
* @param Array($tags)
* @param array $tags
*
* @return array
*/
......@@ -210,13 +225,12 @@ class BlogsRepository extends BaseRepository
*/
public function uploadImage($input)
{
$uploadManager = new FileUploads();
$avatar = $input['featured_image'];
if (isset($input['featured_image']) && !empty($input['featured_image'])) {
$fileName = $uploadManager->setBasePath('backend/blog_images')
->setThumbnailFlag(false)
->upload($input['featured_image']);
$fileName = time().$avatar->getClientOriginalName();
$this->storage->put($this->upload_path.$fileName, file_get_contents($avatar->getRealPath()));
$input = array_merge($input, ['featured_image' => $fileName]);
......@@ -231,11 +245,8 @@ class BlogsRepository extends BaseRepository
*/
public function deleteOldFile($model)
{
$uploadManager = new FileUploads();
$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
public function getForDataTable()
{
return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.pages.table').'.created_by')
->select([
config('module.pages.table').'.id',
config('module.pages.table').'.title',
config('module.pages.table').'.status',
config('module.pages.table').'.created_at',
config('module.pages.table').'.updated_at',
config('access.users_table').'.first_name as created_by',
]);
}
......@@ -47,10 +49,10 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
}
//Making extra fields
// Making extra fields
$input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0;
$input['created_by'] = access()->user()->id;
$input['created_by'] = auth()->id();
if ($page = Page::create($input)) {
event(new PageCreated($page));
......@@ -75,7 +77,7 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
}
//Making extra fields
// Making extra fields
$input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0;
$input['updated_by'] = access()->user()->id;
......
......@@ -5,6 +5,7 @@ namespace App\Repositories\Backend\Settings;
use App\Exceptions\GeneralException;
use App\Models\Settings\Setting;
use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\Storage;
/**
* Class SettingsRepository.
......@@ -16,24 +17,57 @@ class SettingsRepository extends BaseRepository
*/
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 $input
* @param array $input
*
* @throws \App\Exceptions\GeneralException
*
* return bool
* @return bool
*/
public function update(Setting $setting, array $input)
{
if (isset($input['logo'])) {
$image_upload = $this->uploadlogoimage($setting, $input['logo']);
$input['logo'] = $image_upload;
if (!empty($input['logo'])) {
$this->removeLogo($setting, 'logo');
$input['logo'] = $this->uploadLogo($setting, $input['logo'], 'logo');
}
if (isset($input['favicon'])) {
$image_upload = $this->uploadfaviconimage($setting, $input['favicon']);
$input['favicon'] = $image_upload;
if (!empty($input['favicon'])) {
$this->removeLogo($setting, 'favicon');
$input['favicon'] = $this->uploadLogo($setting, $input['favicon'], 'favicon');
}
if ($setting->update($input)) {
......@@ -46,63 +80,34 @@ class SettingsRepository extends BaseRepository
/*
* Upload logo image
*/
public function uploadlogoimage($setting, $logo)
public function uploadLogo($setting, $logo, $type)
{
$image_name_ex = $logo->getClientOriginalExtension();
if ($setting->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting->logo)) {
unlink('img/site_logo/'.$setting->logo);
}
}
$path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
$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;
}
/*
* 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 (file_exists(public_path().'/img/favicon_icon/'.$setting->favicon)) {
unlink('img/favicon_icon/'.$setting->favicon);
}
if ($setting->$type && $this->storage->exists($path.$setting->$type)) {
$this->storage->delete($path.$setting->$type);
}
$image_name = time().$logo->getClientOriginalName();
$destinationPath = public_path('/img/favicon_icon');
$logo->move($destinationPath, $image_name);
$result = $setting->update([$type => null]);
return $image_name;
if ($result) {
return true;
}
/*
* 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]);
}
throw new GeneralException(trans('exceptions.backend.settings.update_error'));
}
}
......@@ -79,6 +79,8 @@ class UserRepository extends BaseRepository
}
/**
* Create User.
*
* @param array $data
* @param bool $provider
*
......@@ -94,11 +96,28 @@ class UserRepository extends BaseRepository
$user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->status = 1;
$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'];
// 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) {
if ($user->save()) {
/*
* Add the default site role to the new user
*/
......@@ -304,4 +323,20 @@ class UserRepository extends BaseRepository
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 @@
"keywords": [
"framework",
"laravel",
"boilerplate"
"boilerplate",
"adminpanel",
"rest-api"
],
"license": "MIT",
"type": "project",
......@@ -12,6 +14,7 @@
"php": ">=7.0.0",
"arcanedev/log-viewer": "^4.4",
"arcanedev/no-captcha": "^5.0",
"codedungeon/phpunit-result-printer": "0.4.4",
"creativeorange/gravatar": "~1.0",
"davejamesmiller/laravel-breadcrumbs": "^4.1",
"doctrine/dbal": "^2.6",
......@@ -54,6 +57,9 @@
},
"classmap": [
"tests/TestCase.php"
],
"files": [
"tests/Utilities/helpers.php"
]
},
"scripts": {
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "35bd90d8d234415b1df889e0e8134318",
"content-hash": "a9ca8bd1e8e71ad163a9d99a2eaee057",
"packages": [
{
"name": "arcanedev/log-viewer",
......@@ -193,6 +193,54 @@
],
"time": "2017-09-07T16:25:53+00:00"
},
{
"name": "codedungeon/phpunit-result-printer",
"version": "0.4.4",
"source": {
"type": "git",
"url": "https://github.com/mikeerickson/phpunit-pretty-result-printer.git",
"reference": "1f41a61732ad267af9fe9ab6b5eefae029c616d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mikeerickson/phpunit-pretty-result-printer/zipball/1f41a61732ad267af9fe9ab6b5eefae029c616d0",
"reference": "1f41a61732ad267af9fe9ab6b5eefae029c616d0",
"shasum": ""
},
"require": {
"hassankhan/config": "^0.10.0",
"symfony/yaml": "^3.3|^4.0"
},
"require-dev": {
"phpunit/phpunit": ">=5.2",
"spatie/phpunit-watcher": "^1.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Codedungeon\\PHPUnitPrettyResultPrinter\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike Erickson",
"email": "codedungeon@gmail.com"
}
],
"description": "PHPUnit Pretty Result Printer",
"keywords": [
"composer",
"package",
"phpunit",
"printer",
"result-printer"
],
"time": "2017-12-22T18:50:24+00:00"
},
{
"name": "creativeorange/gravatar",
"version": "1.0.10",
......@@ -1145,6 +1193,63 @@
],
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "hassankhan/config",
"version": "0.10.0",
"source": {
"type": "git",
"url": "https://github.com/hassankhan/config.git",
"reference": "06ac500348af033f1a2e44dc357ca86282626d4a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hassankhan/config/zipball/06ac500348af033f1a2e44dc357ca86282626d4a",
"reference": "06ac500348af033f1a2e44dc357ca86282626d4a",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"scrutinizer/ocular": "~1.1",
"squizlabs/php_codesniffer": "~2.2"
},
"suggest": {
"symfony/yaml": "~2.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Noodlehaus\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Hassan Khan",
"homepage": "http://hassankhan.me/",
"role": "Developer"
}
],
"description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files",
"homepage": "http://hassankhan.me/config/",
"keywords": [
"config",
"configuration",
"ini",
"json",
"microphp",
"unframework",
"xml",
"yaml",
"yml"
],
"time": "2016-02-11T16:21:17+00:00"
},
{
"name": "hieu-le/active",
"version": "3.5.1",
......@@ -1367,16 +1472,16 @@
},
{
"name": "laravel/framework",
"version": "v5.5.26",
"version": "v5.5.28",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "d7e6a7aab600c5cfae595ea22074ac3c536cbc28"
"reference": "cfafae1f2043208390a7c984e3070696f4969605"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/d7e6a7aab600c5cfae595ea22074ac3c536cbc28",
"reference": "d7e6a7aab600c5cfae595ea22074ac3c536cbc28",
"url": "https://api.github.com/repos/laravel/framework/zipball/cfafae1f2043208390a7c984e3070696f4969605",
"reference": "cfafae1f2043208390a7c984e3070696f4969605",
"shasum": ""
},
"require": {
......@@ -1497,7 +1602,7 @@
"framework",
"laravel"
],
"time": "2017-12-18T14:15:59+00:00"
"time": "2017-12-26T16:24:40+00:00"
},
{
"name": "laravel/socialite",
......@@ -2075,16 +2180,16 @@
},
{
"name": "nikic/php-parser",
"version": "v3.1.2",
"version": "v3.1.3",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "08131e7ff29de6bb9f12275c7d35df71f25f4d89"
"reference": "579f4ce846734a1cf55d6a531d00ca07a43e3cda"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/08131e7ff29de6bb9f12275c7d35df71f25f4d89",
"reference": "08131e7ff29de6bb9f12275c7d35df71f25f4d89",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/579f4ce846734a1cf55d6a531d00ca07a43e3cda",
"reference": "579f4ce846734a1cf55d6a531d00ca07a43e3cda",
"shasum": ""
},
"require": {
......@@ -2122,7 +2227,7 @@
"parser",
"php"
],
"time": "2017-11-04T11:48:34+00:00"
"time": "2017-12-26T14:43:21+00:00"
},
{
"name": "paragonie/random_compat",
......@@ -2368,16 +2473,16 @@
},
{
"name": "psy/psysh",
"version": "v0.8.16",
"version": "v0.8.17",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "d4c8eab0683dc056f2ca54ca67f5388527c068b1"
"reference": "5069b70e8c4ea492c2b5939b6eddc78bfe41cfec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/d4c8eab0683dc056f2ca54ca67f5388527c068b1",
"reference": "d4c8eab0683dc056f2ca54ca67f5388527c068b1",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/5069b70e8c4ea492c2b5939b6eddc78bfe41cfec",
"reference": "5069b70e8c4ea492c2b5939b6eddc78bfe41cfec",
"shasum": ""
},
"require": {
......@@ -2436,7 +2541,7 @@
"interactive",
"shell"
],
"time": "2017-12-10T21:49:27+00:00"
"time": "2017-12-28T16:14:16+00:00"
},
{
"name": "ramsey/uuid",
......@@ -2577,16 +2682,16 @@
},
{
"name": "symfony/console",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e"
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/9f21adfb92a9315b73ae2ed43138988ee4913d4e",
"reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e",
"url": "https://api.github.com/repos/symfony/console/zipball/8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"shasum": ""
},
"require": {
......@@ -2642,20 +2747,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "symfony/css-selector",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "eac760b414cf1f64362c3dd047b989e4db121332"
"reference": "e66394bc7610e69279bfdb3ab11b4fe65403f556"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/eac760b414cf1f64362c3dd047b989e4db121332",
"reference": "eac760b414cf1f64362c3dd047b989e4db121332",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/e66394bc7610e69279bfdb3ab11b4fe65403f556",
"reference": "e66394bc7610e69279bfdb3ab11b4fe65403f556",
"shasum": ""
},
"require": {
......@@ -2695,20 +2800,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "symfony/debug",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "543deab3ffff94402440b326fc94153bae2dfa7a"
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/543deab3ffff94402440b326fc94153bae2dfa7a",
"reference": "543deab3ffff94402440b326fc94153bae2dfa7a",
"url": "https://api.github.com/repos/symfony/debug/zipball/603b95dda8b00020e4e6e60dc906e7b715b1c245",
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245",
"shasum": ""
},
"require": {
......@@ -2751,20 +2856,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2017-12-12T08:27:14+00:00"
"time": "2018-01-03T17:14:19+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v4.0.2",
"version": "v4.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "d4face19ed8002eec8280bc1c5ec18130472bf43"
"reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d4face19ed8002eec8280bc1c5ec18130472bf43",
"reference": "d4face19ed8002eec8280bc1c5ec18130472bf43",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74d33aac36208c4d6757807d9f598f0133a3a4eb",
"reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb",
"shasum": ""
},
"require": {
......@@ -2814,20 +2919,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2017-12-14T19:48:22+00:00"
"time": "2018-01-03T07:38:00+00:00"
},
{
"name": "symfony/finder",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a"
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a",
"url": "https://api.github.com/repos/symfony/finder/zipball/613e26310776f49a1773b6737c6bd554b8bc8c6f",
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f",
"shasum": ""
},
"require": {
......@@ -2863,20 +2968,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2017-11-05T16:10:10+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "59bf131b5460227a2f583a7dbe6b179f98f9e0a5"
"reference": "4a213be1cc8598089b8c7451529a2927b49b5d26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/59bf131b5460227a2f583a7dbe6b179f98f9e0a5",
"reference": "59bf131b5460227a2f583a7dbe6b179f98f9e0a5",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/4a213be1cc8598089b8c7451529a2927b49b5d26",
"reference": "4a213be1cc8598089b8c7451529a2927b49b5d26",
"shasum": ""
},
"require": {
......@@ -2917,20 +3022,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00"
"time": "2018-01-03T17:14:19+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "48325096bbda77b983e642d21a4dd9bdde3ab73e"
"reference": "1c2a82d6a8ec9b354fe4ef48ad1ad3f1a4f7db0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/48325096bbda77b983e642d21a4dd9bdde3ab73e",
"reference": "48325096bbda77b983e642d21a4dd9bdde3ab73e",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/1c2a82d6a8ec9b354fe4ef48ad1ad3f1a4f7db0e",
"reference": "1c2a82d6a8ec9b354fe4ef48ad1ad3f1a4f7db0e",
"shasum": ""
},
"require": {
......@@ -3005,7 +3110,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2017-12-15T02:05:18+00:00"
"time": "2018-01-05T08:33:00+00:00"
},
{
"name": "symfony/polyfill-mbstring",
......@@ -3235,16 +3340,16 @@
},
{
"name": "symfony/process",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "bb3ef65d493a6d57297cad6c560ee04e2a8f5098"
"reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/bb3ef65d493a6d57297cad6c560ee04e2a8f5098",
"reference": "bb3ef65d493a6d57297cad6c560ee04e2a8f5098",
"url": "https://api.github.com/repos/symfony/process/zipball/ff69f110c6b33fd33cd2089ba97d6112f44ef0ba",
"reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba",
"shasum": ""
},
"require": {
......@@ -3280,20 +3385,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "symfony/routing",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "5f248dfac5e4660c74982eb3dadc71cf58595570"
"reference": "e2b6d6fe7b090c7af720b75c7722c6dfa7a52658"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/5f248dfac5e4660c74982eb3dadc71cf58595570",
"reference": "5f248dfac5e4660c74982eb3dadc71cf58595570",
"url": "https://api.github.com/repos/symfony/routing/zipball/e2b6d6fe7b090c7af720b75c7722c6dfa7a52658",
"reference": "e2b6d6fe7b090c7af720b75c7722c6dfa7a52658",
"shasum": ""
},
"require": {
......@@ -3358,20 +3463,20 @@
"uri",
"url"
],
"time": "2017-12-14T22:37:31+00:00"
"time": "2018-01-04T15:09:34+00:00"
},
{
"name": "symfony/translation",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "4c5d5582baf2829751a5207659329c1f52eedeb6"
"reference": "17b5962d252b2d6d1d37a2485ebb7ddc5b2bef0a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/4c5d5582baf2829751a5207659329c1f52eedeb6",
"reference": "4c5d5582baf2829751a5207659329c1f52eedeb6",
"url": "https://api.github.com/repos/symfony/translation/zipball/17b5962d252b2d6d1d37a2485ebb7ddc5b2bef0a",
"reference": "17b5962d252b2d6d1d37a2485ebb7ddc5b2bef0a",
"shasum": ""
},
"require": {
......@@ -3426,20 +3531,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2017-12-12T08:27:14+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "757074cf71b952ce9e75b557538948811c2bf006"
"reference": "545be7e78ccbec43e599f10ff7500d0b09eda9d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/757074cf71b952ce9e75b557538948811c2bf006",
"reference": "757074cf71b952ce9e75b557538948811c2bf006",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/545be7e78ccbec43e599f10ff7500d0b09eda9d0",
"reference": "545be7e78ccbec43e599f10ff7500d0b09eda9d0",
"shasum": ""
},
"require": {
......@@ -3495,7 +3600,65 @@
"debug",
"dump"
],
"time": "2017-12-11T22:06:16+00:00"
"time": "2018-01-03T17:14:19+00:00"
},
{
"name": "symfony/yaml",
"version": "v4.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "b84f646b9490d2101e2c25ddeec77ceefbda2eee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/b84f646b9490d2101e2c25ddeec77ceefbda2eee",
"reference": "b84f646b9490d2101e2c25ddeec77ceefbda2eee",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "~3.4|~4.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:38:00+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
......@@ -3620,16 +3783,16 @@
},
{
"name": "unisharp/laravel-filemanager",
"version": "v1.8.3",
"version": "v1.8.4",
"source": {
"type": "git",
"url": "https://github.com/UniSharp/laravel-filemanager.git",
"reference": "40ff56023e932c01b20dde0619b5fa81f17df06d"
"reference": "ccbba303a3a66a9706b50c98923af12e2f9ac02a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/UniSharp/laravel-filemanager/zipball/40ff56023e932c01b20dde0619b5fa81f17df06d",
"reference": "40ff56023e932c01b20dde0619b5fa81f17df06d",
"url": "https://api.github.com/repos/UniSharp/laravel-filemanager/zipball/ccbba303a3a66a9706b50c98923af12e2f9ac02a",
"reference": "ccbba303a3a66a9706b50c98923af12e2f9ac02a",
"shasum": ""
},
"require": {
......@@ -3690,7 +3853,7 @@
"tinymce",
"upload"
],
"time": "2017-12-05T17:21:15+00:00"
"time": "2017-12-28T09:23:53+00:00"
},
{
"name": "vlucas/phpdotenv",
......@@ -4996,16 +5159,16 @@
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "5.0.5",
"version": "5.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933"
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/283b9f4f670e3a6fd6c4ff95c51a952eb5c75933",
"reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"shasum": ""
},
"require": {
......@@ -5051,7 +5214,7 @@
"mock",
"xunit"
],
"time": "2017-12-10T08:01:53+00:00"
"time": "2018-01-06T05:45:45+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
......@@ -5100,16 +5263,16 @@
},
{
"name": "sebastian/comparator",
"version": "2.1.0",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "1174d9018191e93cb9d719edec01257fc05f8158"
"reference": "b11c729f95109b56a0fe9650c6a63a0fcd8c439f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1174d9018191e93cb9d719edec01257fc05f8158",
"reference": "1174d9018191e93cb9d719edec01257fc05f8158",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/b11c729f95109b56a0fe9650c6a63a0fcd8c439f",
"reference": "b11c729f95109b56a0fe9650c6a63a0fcd8c439f",
"shasum": ""
},
"require": {
......@@ -5160,7 +5323,7 @@
"compare",
"equality"
],
"time": "2017-11-03T07:16:52+00:00"
"time": "2017-12-22T14:50:35+00:00"
},
{
"name": "sebastian/diff",
......@@ -5614,16 +5777,16 @@
},
{
"name": "symfony/dom-crawler",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "dc847845c66fa68ad4522ed27e62b9b9dd12ab3b"
"reference": "09bd97b844b3151fab82f2fdd62db9c464b3910a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/dc847845c66fa68ad4522ed27e62b9b9dd12ab3b",
"reference": "dc847845c66fa68ad4522ed27e62b9b9dd12ab3b",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/09bd97b844b3151fab82f2fdd62db9c464b3910a",
"reference": "09bd97b844b3151fab82f2fdd62db9c464b3910a",
"shasum": ""
},
"require": {
......@@ -5666,7 +5829,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "theseer/tokenizer",
......
......@@ -88,7 +88,7 @@ return [
/*
* 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
......@@ -105,6 +105,12 @@ return [
* Whether or not the users email can be changed on the edit profile screen
*/
'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
use App\Models\Access\Role\Role;
use App\Models\Access\User\User;
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) {
static $password;
return [
'name' => $faker->name,
'first_name' => $faker->name,
'last_name' => $faker->name,
'email' => $faker->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'confirmation_code' => md5(uniqid(mt_rand(), true)),
'remember_token' => str_random(10),
];
});
......@@ -50,20 +39,3 @@ $factory->state(User::class, 'unconfirmed', function () {
'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
//Add the master administrator, user id of 1
$users = [
[
'first_name' => 'Admin Istrator',
'last_name' => 'Admin Istrator',
'first_name' => 'Viral',
'last_name' => 'Solani',
'email' => 'admin@admin.com',
'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)),
......@@ -39,8 +39,8 @@ class UserTableSeeder extends Seeder
'deleted_at' => null,
],
[
'first_name' => 'Backend User',
'last_name' => 'Admin Istrator',
'first_name' => 'Vipul',
'last_name' => 'Basapati',
'email' => 'executive@executive.com',
'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)),
......@@ -52,8 +52,8 @@ class UserTableSeeder extends Seeder
'deleted_at' => null,
],
[
'first_name' => 'Default User',
'last_name' => 'Admin Istrator',
'first_name' => 'User',
'last_name' => 'Test',
'email' => 'user@user.com',
'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)),
......
......@@ -18,7 +18,7 @@ class MenuTableSeeder extends Seeder
'id' => 1,
'type' => 'backend',
'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_at' => Carbon::now(),
];
......
......@@ -7,7 +7,8 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
<testsuites>
<testsuite name="Feature Tests">
<directory suffix="Test.php">./tests/Feature</directory>
......
var associated = $("select[name='associated-permissions']");
var associated = $("select[name='associated_permissions']");
var associated_container = $("#available-permissions");
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 [
'already_confirmed' => 'Your account is already confirmed.',
'confirm' => '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.',
'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.',
......
......@@ -66,7 +66,7 @@ return [
'active' => 'Active Users',
'all_permissions' => 'All Permissions',
'change_password' => 'Change Password',
'change_password_for' => 'Change Password :user',
'change_password_for' => 'Change Password for :user',
'create' => 'Create User',
'deactivated' => 'Deactivated Users',
'deleted' => 'Deleted Users',
......@@ -126,6 +126,7 @@ return [
'status' => 'Status',
'createdat' => 'Created At',
'updatedat' => 'Updated At',
'createdby' => 'Created By',
'all' => 'All',
],
],
......@@ -200,7 +201,7 @@ return [
'companydetails' => 'Company Contact Details',
'mail' => 'Mail Settings',
'footer' => 'Footer Settings',
'terms' => 'Terms & Condition Settings',
'terms' => 'Terms and Condition Settings',
'google' => 'Google Analytics Track Code',
],
......
......@@ -6,7 +6,7 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<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="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>
......
......@@ -31,10 +31,10 @@
</div><!--form control-->
<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">
{{ 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 class="row">
......
......@@ -31,15 +31,10 @@
</div><!--form control-->
<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">
@if ($role->id != 1)
{{-- 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
{{ Form::select('associated_permissions', ['all' => 'All', 'custom' => 'Custom'], $role->all ? 'all' : 'custom', ['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 class="row">
......
......@@ -120,7 +120,7 @@
@foreach($roles as $role)
<div>
<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>
<a href="#" data-role="role_{{ $role->id }}" class="show-permissions small">
(
......@@ -220,6 +220,7 @@
});
});
$("#role-3").click();
});
</script>
@endsection
......@@ -10,7 +10,7 @@
@endsection
@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-header with-border">
......@@ -26,7 +26,7 @@
<div class="form-group">
@include("backend.blogcategories.form")
<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']) }}
<div class="clearfix"></div>
</div>
......
......@@ -10,7 +10,7 @@
@endsection
@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-header with-border">
......@@ -26,7 +26,7 @@
<div class="form-group">
@include("backend.blogcategories.form")
<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']) }}
<div class="clearfix"></div>
</div>
......
......@@ -70,7 +70,7 @@
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.blogcategories.get") }}',
url: '{{ route("admin.blogCategories.get") }}',
type: 'post'
},
columns: [
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/blogcategories'))
@if(Active::checkUriPattern('admin/blogCategories'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
......@@ -21,9 +21,9 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<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')
<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
</ul>
</div>
\ No newline at end of file
......@@ -35,7 +35,7 @@
{{ Form::label('featured_image', trans('validation.attributes.backend.blogs.image'), ['class' => 'col-lg-2 control-label required']) }}
@if(!empty($blog->featured_image))
<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 class="col-lg-5">
<div class="custom-file-input">
......
......@@ -10,7 +10,7 @@
@endsection
@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-header with-border">
......@@ -26,7 +26,7 @@
<div class="form-group">
@include("backend.blogtags.form")
<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']) }}
<div class="clearfix"></div>
</div>
......
......@@ -10,7 +10,7 @@
@endsection
@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-header with-border">
......@@ -26,7 +26,7 @@
<div class="form-group">
@include("backend.blogtags.form")
<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']) }}
<div class="clearfix"></div>
</div>
......
......@@ -70,7 +70,7 @@
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.blogtags.get") }}',
url: '{{ route("admin.blogTags.get") }}',
type: 'post'
},
columns: [
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/blogtags'))
@if(Active::checkUriPattern('admin/blogTags'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
......@@ -21,9 +21,9 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<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')
<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
</ul>
</div>
......
......@@ -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;') }}">
@permission('view-blog-category')
<li class="{{ active_class(Active::checkUriPattern('admin/blogcategories*')) }}">
<a href="{{ route('admin.blogcategories.index') }}">
<li class="{{ active_class(Active::checkUriPattern('admin/blogCategories*')) }}">
<a href="{{ route('admin.blogCategories.index') }}">
<span>{{ trans('menus.backend.blogcategories.management') }}</span>
</a>
</li>
@endauth
@permission('view-blog-tag')
<li class="{{ active_class(Active::checkUriPattern('admin/blogtags*')) }}">
<a href="{{ route('admin.blogtags.index') }}">
<li class="{{ active_class(Active::checkUriPattern('admin/blogTags*')) }}">
<a href="{{ route('admin.blogTags.index') }}">
<span>{{ trans('menus.backend.blogtags.management') }}</span>
</a>
</li>
......@@ -111,6 +111,9 @@
</li>
@endauth
</ul>
</li>
@endauth
@permission('view-faq')
<li class="{{ active_class(Active::checkUriPattern('admin/faqs*')) }}">
<a href="{{ route('admin.faqs.index')}}">
......@@ -119,8 +122,6 @@
</a>
</li>
@endauth
</li>
@endauth
<li class="{{ active_class(Active::checkUriPattern('admin/log-viewer*')) }} treeview">
<a href="#">
......
......@@ -24,7 +24,7 @@
<th>{{ trans('labels.backend.pages.table.title') }}</th>
<th>{{ trans('labels.backend.pages.table.status') }}</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>
</tr>
</thead>
......@@ -77,10 +77,10 @@
{data: 'title', name: '{{config('module.pages.table')}}.title'},
{data: 'status', name: '{{config('module.pages.table')}}.status'},
{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}
],
order: [[3, "asc"]],
order: [[1, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
......
......@@ -3,167 +3,228 @@
@section ('title', trans('labels.backend.settings.management') . ' | ' . trans('labels.backend.settings.edit'))
@section('page-header')
<h1>
<h1>
{{ trans('labels.backend.settings.management') }}
<small>{{ trans('labels.backend.settings.edit') }}</small>
</h1>
</h1>
@endsection
@section('content')
{{ Form::model($setting, ['route' => ['admin.settings.update', $setting], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH','files' => true, 'id' => 'edit-role']) }}
{{ Form::model($setting, ['route' => ['admin.settings.update', $setting], 'class' => 'form-horizontal',
'role' => 'form', 'method' => 'PATCH','files' => true, 'id' => 'edit-settings']) }}
<div class="box box-info">
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">{{ trans('labels.backend.settings.edit') }}</h3>
</div><!-- /.box-header -->
</div>
<!-- /.box-header -->
<div class="box-body setting-block">
<!-- Nav tabs -->
<ul id="myTab" class="nav nav-tabs setting-tab-list" role="tablist">
<li role="presentation" class="active"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.seo') }}</a></li>
<li role="presentation"><a href="#tab2" aria-controls="1" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.companydetails') }}</a></li>
<li role="presentation"><a href="#tab3" aria-controls="2" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.mail') }}</a></li>
<li role="presentation"><a href="#tab4" aria-controls="3" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.footer') }}</a></li>
<li role="presentation"><a href="#tab5" aria-controls="4" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.terms') }}</a></li>
<li role="presentation"><a href="#tab6" aria-controls="5" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.google') }}</a></li>
<li role="presentation" class="active">
<a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.seo') }}</a>
</li>
<li role="presentation">
<a href="#tab2" aria-controls="1" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.companydetails') }}</a>
</li>
<li role="presentation">
<a href="#tab3" aria-controls="2" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.mail') }}</a>
</li>
<li role="presentation">
<a href="#tab4" aria-controls="3" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.footer') }}</a>
</li>
<li role="presentation">
<a href="#tab5" aria-controls="4" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.terms') }}</a>
</li>
<li role="presentation">
<a href="#tab6" aria-controls="5" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.google') }}</a>
</li>
</ul>
<!-- Tab panes -->
<div id="myTabContent" class="tab-content setting-tab">
<div role="tabpanel" class="tab-pane active" id="tab1">
<div class="form-group">
{{ Form::label('logo', trans('validation.attributes.backend.settings.sitelogo'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('logo', trans('validation.attributes.backend.settings.sitelogo'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
<div class="custom-file-input">
{!! Form::file('logo', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="logo"><i class="fa fa-upload"></i><span>Choose a file</span></label>
<label for="logo">
<i class="fa fa-upload"></i>
<span>Choose a file</span>
</label>
</div>
<div class="img-remove-logo">
@if($setting->logo)
<img height="50" width="50" src="{{url('/img/site_logo/')}}/{{$setting->logo}}">
<img height="50" width="50" src="{{ Storage::disk('public')->url('img/logo/' . $setting->logo) }}">
<i id="remove-logo-img" class="fa fa-times remove-logo" data-id="logo" aria-hidden="true"></i>
@endif
</div>
</div><!--col-lg-10-->
</div><!--form control-->
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('favicon', trans('validation.attributes.backend.settings.favicon'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('favicon', trans('validation.attributes.backend.settings.favicon'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
<div class="custom-file-input">
{!! Form::file('favicon', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="favicon"><i class="fa fa-upload"></i><span>Choose a file</span></label>
<label for="favicon">
<i class="fa fa-upload"></i>
<span>Choose a file</span>
</label>
</div>
<div class="img-remove-favicon">
@if($setting->favicon)
<img height="50" width="50" src="{{url('/img/favicon_icon/')}}/{{$setting->favicon}}">
<img height="50" width="50" src="{{ Storage::disk('public')->url('img/favicon/' . $setting->favicon) }}">
<i id="remove-favicon-img" class="fa fa-times remove-logo" data-id="favicon" aria-hidden="true"></i>
@endif
</div>
</div><!--col-lg-10-->
</div><!--form control-->
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('seo_title', trans('validation.attributes.backend.settings.metatitle'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('seo_title', trans('validation.attributes.backend.settings.metatitle'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('seo_title', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metatitle')]) }}
</div><!--col-lg-10-->
</div><!--form control-->
{{ Form::text('seo_title', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metatitle')])
}}
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('seo_keyword', trans('validation.attributes.backend.settings.metakeyword'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('seo_keyword', trans('validation.attributes.backend.settings.metakeyword'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::textarea('seo_keyword', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metakeyword'), 'rows' => 2]) }}
</div><!--col-lg-3-->
</div><!--form control-->
{{ Form::textarea('seo_keyword', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metakeyword'),
'rows' => 2]) }}
</div>
<!--col-lg-3-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('seo_description', trans('validation.attributes.backend.settings.metadescription'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('seo_description', trans('validation.attributes.backend.settings.metadescription'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metadescription'), 'rows' => 2]) }}
</div><!--col-lg-3-->
</div><!--form control-->
{{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metadescription'),
'rows' => 2]) }}
</div>
<!--col-lg-3-->
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab2">
<div class="form-group">
{{ Form::label('company_address', trans('validation.attributes.backend.settings.companydetails.address'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('company_address', trans('validation.attributes.backend.settings.companydetails.address'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('company_address', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.address'), 'rows' => 2]) }}
{{ Form::textarea('company_address', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.address'),
'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('company_contact', trans('validation.attributes.backend.settings.companydetails.contactnumber'), ['class' => 'col-lg-2 control-label']) }}
<div class="form-group">
{{ Form::label('company_contact', trans('validation.attributes.backend.settings.companydetails.contactnumber'), ['class'
=> 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('company_contact', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.contactnumber'), 'rows' => 2]) }}
{{ Form::text('company_contact', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.contactnumber'),
'rows' => 2]) }}
</div>
</div>
</div><!--form control-->
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab3">
<div class="form-group">
{{ Form::label('from_name', trans('validation.attributes.backend.settings.mail.fromname'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('from_name', trans('validation.attributes.backend.settings.mail.fromname'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('from_name', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromname'), 'rows' => 2]) }}
{{ Form::text('from_name', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromname'),
'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('from_email', trans('validation.attributes.backend.settings.mail.fromemail'), ['class' => 'col-lg-2 control-label required']) }}
<div class="form-group">
{{ Form::label('from_email', trans('validation.attributes.backend.settings.mail.fromemail'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('from_email', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromemail'), 'rows' => 2]) }}
{{ Form::text('from_email', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromemail'),
'rows' => 2]) }}
</div>
</div>
</div><!--form control-->
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab4">
<div class="form-group">
{{ Form::label('footer_text', trans('validation.attributes.backend.settings.footer.text'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('footer_text', trans('validation.attributes.backend.settings.footer.text'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('footer_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.text'), 'rows' => 2]) }}
{{ Form::text('footer_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.text'),
'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('copyright_text', trans('validation.attributes.backend.settings.footer.copyright'), ['class' => 'col-lg-2 control-label']) }}
<div class="form-group">
{{ Form::label('copyright_text', trans('validation.attributes.backend.settings.footer.copyright'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::text('copyright_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.copyright'), 'rows' => 2]) }}
{{ Form::text('copyright_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.copyright'),
'rows' => 2]) }}
</div>
</div>
</div><!--form control-->
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab5">
<div class="form-group">
{{ Form::label('terms', trans('validation.attributes.backend.settings.termscondition.terms'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('terms', trans('validation.attributes.backend.settings.termscondition.terms'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::textarea('terms', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.terms')]) }}
{{ Form::textarea('terms', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.terms')])
}}
</div>
</div>
<div class="form-group">
{{ Form::label('disclaimer', trans('validation.attributes.backend.settings.termscondition.disclaimer'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('disclaimer', trans('validation.attributes.backend.settings.termscondition.disclaimer'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('disclaimer', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.disclaimer')]) }}
{{ Form::textarea('disclaimer', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.disclaimer')])
}}
</div>
</div><!--form control-->
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab6">
<div class="form-group">
{{ Form::label('google_analytics', trans('validation.attributes.backend.settings.google.analytic'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('google_analytics', trans('validation.attributes.backend.settings.google.analytic'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('google_analytics', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.google.analytic')]) }}
{{ Form::textarea('google_analytics', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.google.analytic')])
}}
</div>
</div>
<!--form control-->
</div>
</div><!--form control-->
</div>
</div>
</div><!-- /.box-body -->
<!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-lg-offset-2 col-lg-10 footer-btn">
......@@ -172,14 +233,24 @@
</div>
</div>
</div>
</div><!--box-->
{{ Form::close() }}
</div><!--box-->
<!-- hidden setting id variable -->
<input type="hidden" data-id="{{ $setting->id }}" id="setting">
{{ Form::close() }}
@endsection
@section('after-scripts')
<script src='/js/backend/bootstrap-tabcollapse.js'></script>
<script>
$('.remove-logo').click(function(){
var data_id = $(this).data('id');
var route = "{{ route('admin.removeIcon', -1) }}";
var data_id = $('#setting').data('id');
route = route.replace('-1', data_id);
$('.remove-logo').click(function() {
var data = $(this).data('id');
swal({
title: "Warning",
text: "Are you sure you want to remove?",
......@@ -191,7 +262,7 @@
}, function (confirmed) {
if (confirmed)
{
var data = data_id;
console.log(data);
if(data=='logo')
{
value= 'logo';
......@@ -203,7 +274,7 @@
$('.img-remove-favicon').addClass('hidden');
}
$.ajax({
url: "{{route('admin.removeicon')}}",
url: route,
type: "POST",
data: {data: value},
});
......@@ -215,5 +286,6 @@
tabsClass: 'hidden-sm hidden-xs',
accordionClass: 'visible-sm visible-xs'
});
</script>
@endsection
\ No newline at end of file
......@@ -4,9 +4,9 @@
* Blogs Categories Management
*/
Route::group(['namespace' => 'BlogCategories'], function () {
Route::resource('blogcategories', 'BlogCategoriesController', ['except' => ['show']]);
Route::resource('blogCategories', 'BlogCategoriesController', ['except' => ['show']]);
//For DataTables
Route::post('blogcategories/get', 'BlogCategoriesTableController')
->name('blogcategories.get');
Route::post('blogCategories/get', 'BlogCategoriesTableController')
->name('blogCategories.get');
});
......@@ -4,9 +4,9 @@
* Blogs Tags Management
*/
Route::group(['namespace' => 'BlogTags'], function () {
Route::resource('blogtags', 'BlogTagsController', ['except' => ['show']]);
Route::resource('blogTags', 'BlogTagsController', ['except' => ['show']]);
//For DataTables
Route::post('blogtags/get', 'BlogTagsTableController')
->name('blogtags.get');
Route::post('blogTags/get', 'BlogTagsTableController')
->name('blogTags.get');
});
......@@ -6,5 +6,5 @@
Route::group(['namespace' => 'Settings'], function () {
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 @@
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;
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');
}
}
<?php
namespace Tests\Feature\Backend;
use App\Events\Backend\Access\User\UserCreated;
use App\Events\Backend\Access\User\UserDeactivated;
use App\Events\Backend\Access\User\UserDeleted;
use App\Events\Backend\Access\User\UserPermanentlyDeleted;
use App\Events\Backend\Access\User\UserReactivated;
use App\Events\Backend\Access\User\UserRestored;
use App\Events\Backend\Access\User\UserUpdated;
use App\Models\Access\Permission\Permission;
use App\Models\Access\Role\Role;
use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use Carbon\Carbon;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class ManageUsersTest extends TestCase
{
/**
* Create User.
*
* @param $overrides
*
* @return [array] User array
*/
protected function createUser($overrides = [])
{
$user = factory(User::class, $overrides = [])->states('active', 'confirmed')->make()->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.user.store'), $user);
}
/** @test */
public function a_user_can_view_active_users()
{
$this->actingAs($this->admin)
->get(route('admin.access.user.index'))
->assertViewIs('backend.access.users.index')
->assertSee(trans('labels.backend.access.users.management'))
->assertSee(trans('labels.backend.access.users.active'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_view_deactevated_users()
{
$this->actingAs($this->admin)
->get(route('admin.access.user.deactivated'))
->assertViewIs('backend.access.users.deactivated')
->assertSee(trans('labels.backend.access.users.management'))
->assertSee(trans('labels.backend.access.users.deactivated'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_view_deleted_users()
{
$this->actingAs($this->admin)
->get(route('admin.access.user.deleted'))
->assertViewIs('backend.access.users.deleted')
->assertSee(trans('labels.backend.access.users.management'))
->assertSee(trans('labels.backend.access.users.deleted'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_view_single_user()
{
$this->actingAs($this->admin)
->get('/admin/access/user/'.$this->admin->id)
->assertViewIs('backend.access.users.show')
->assertSee('View User')
->assertSee('Overview')
->assertSee('History')
->assertSee($this->admin->first_name)
->assertSee($this->admin->last_name)
->assertSee($this->admin->email);
}
/** @test */
public function a_user_requires_a_first_name()
{
$this->createUser(['first_name' => null])
->assertSessionHasErrors('first_name');
}
/** @test */
public function a_user_requires_a_last_name()
{
$this->createUser(['last_name' => null])
->assertSessionHasErrors('last_name');
}
/** @test */
public function a_user_requires_a_email()
{
$this->createUser(['email' => null])
->assertSessionHasErrors('email');
}
/** @test */
public function a_user_requires_a_password()
{
$this->createUser(['password' => null])
->assertSessionHasErrors('password');
}
/** @test */
public function a_user_requires_a_confirm_password()
{
$user = factory(User::class)->states('active', 'confirmed')->make()->toArray();
$user['password'] = 'Viral@1234';
$user['password_confirmation'] = 'Viral@1235';
$this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.user.store'), $user)
->assertSessionHasErrors('password');
}
/** @test */
public function a_user_requires_a_role()
{
$this->createUser()
->assertSessionHasErrors('assignees_roles');
}
/** @test */
public function a_user_requires_a_permission()
{
$this->createUser()
->assertSessionHasErrors('permissions');
}
/** @test */
public function create_user_fails_if_email_is_exists()
{
$this->createUser(['email' => 'admin@admin.com'])
->assertSessionHasErrors('email');
}
/** @test */
public function a_user_can_create_new_user()
{
// Make sure our events are fired
Event::fake();
$user = factory(User::class)->states('active', 'confirmed')->make()->toArray();
$role = create(Role::class);
$permission = create(Permission::class);
$user['password'] = 'Viral@1234';
$user['password_confirmation'] = 'Viral@1234';
$user['assignees_roles'] = [$role->id];
$user['permissions'] = [$permission->id];
$this->actingAs($this->admin)
->post(route('admin.access.user.store'), $user)
->assertRedirect(route('admin.access.user.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.created')]);
$this->assertDatabaseHas(config('access.users_table'), [
'first_name' => $user['first_name'],
'last_name' => $user['last_name'],
'email' => $user['email'],
'status' => 1,
'confirmed' => 1,
]);
$this->assertDatabaseHas(config('access.roles_table'), ['name' => $role->name]);
$this->assertDatabaseHas(config('access.permissions_table'), ['name' => $permission->name]);
$this->assertDatabaseHas(config('access.role_user_table'), ['role_id' => $role->id]);
Event::assertDispatched(UserCreated::class);
}
/** @test */
public function an_email_will_be_sent_to_uncomfirmed_user()
{
// Make sure our events are fired
Event::fake();
// Make sure our notifications are sent
Notification::fake();
$user = factory(User::class)->states('active')->make()->toArray();
$role = create(Role::class);
$permission = create(Permission::class);
$user['password'] = 'Viral@1234';
$user['password_confirmation'] = 'Viral@1234';
$user['confirmation_email'] = 1;
$user['assignees_roles'] = [$role->id];
$user['permissions'] = [$permission->id];
$this->actingAs($this->admin)
->post(route('admin.access.user.store'), $user)
->assertRedirect(route('admin.access.user.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.created')]);
$this->assertDatabaseHas(config('access.users_table'), [
'first_name' => $user['first_name'],
'last_name' => $user['last_name'],
'email' => $user['email'],
'status' => 1,
'confirmed' => 0,
]);
$this->assertDatabaseHas(config('access.roles_table'), ['name' => $role->name]);
$this->assertDatabaseHas(config('access.permissions_table'), ['name' => $permission->name]);
$this->assertDatabaseHas(config('access.role_user_table'), ['role_id' => $role->id]);
// Get the user that was inserted into the database
$insertedUser = User::where('email', $user['email'])->first();
// Check that the user was sent the confirmation email
Notification::assertSentTo([$insertedUser], UserNeedsConfirmation::class);
Event::assertDispatched(UserCreated::class);
}
/** @test */
public function it_fails_for_validation_on_update_user()
{
$user = create(User::class);
$user1 = $user->toArray();
$user1['first_name'] = '';
$user1['last_name'] = '';
$user1['email'] = '';
$user1['assignees_roles'] = '';
$user1['permissions'] = '';
$this->withExceptionHandling()
->actingAs($this->admin)
->patch(route('admin.access.user.update', $user), $user1)
->assertSessionHasErrors(['first_name', 'last_name', 'email', 'assignees_roles', 'permissions']);
}
/** @test */
public function a_user_can_update_new_user()
{
Event::fake();
$user = create(User::class);
$role = create(Role::class);
$permission = create(Permission::class);
$data = $user->toArray();
$data['first_name'] = 'updated first_name';
$data['last_name'] = 'updated last_name';
$data['assignees_roles'] = [$role->id];
$data['permissions'] = [$permission->id];
$this->actingAs($this->admin)
->patch(route('admin.access.user.update', $user), $data)
->assertRedirect(route('admin.access.user.index'))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.updated')]);
$this->assertDatabaseHas(config('access.users_table'), [
'id' => $user->id,
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
]);
Event::assertDispatched(UserUpdated::class);
}
/** @test */
public function a_user_can_delete_a_user()
{
Event::fake();
$user = create(User::class);
$this->actingAs($this->admin)
->delete(route('admin.access.user.destroy', $user))
->assertStatus(302)
->assertSessionHas(['flash_success' => trans('alerts.backend.users.deleted')]);
$this->assertDatabaseMissing(config('access.users_table'), [
'name' => $user->first_name,
'id' => $user->id,
]);
Event::assertDispatched(UserDeleted::class);
}
/** @test */
public function a_user_can_not_delete_himself()
{
$this->withExceptionHandling()
->actingAs($this->admin)
->delete(route('admin.access.user.destroy', $this->admin))
->assertSessionHas(['flash_danger' => trans('exceptions.backend.access.users.cant_delete_self')]);
$this->assertDatabaseHas(config('access.users_table'), ['id' => $this->admin->id, 'deleted_at' => null]);
}
/** @test */
public function a_user_can_restore_a_deleted_user()
{
Event::fake();
$this->user->deleted_at = Carbon::now();
$this->user->save();
$this->actingAs($this->admin)
->get(route('admin.access.user.restore', $this->user))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.restored')]);
Event::assertDispatched(UserRestored::class);
}
/** @test */
public function a_user_can_permanently_delete_user()
{
Event::fake();
$this->user->deleted_at = Carbon::now();
$this->user->save();
$this->actingAs($this->admin)
->get(route('admin.access.user.delete-permanently', $this->user))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.deleted_permanently')]);
Event::assertDispatched(UserPermanentlyDeleted::class);
}
/** @test */
public function a_user_can_mark_user_as_inactive_and_active()
{
Event::fake();
$this->actingAs($this->admin)
->get(route('admin.access.user.mark', [$this->user, 0]))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.updated')]);
$this->assertDatabaseHas(config('access.users_table'), ['id' => $this->user->id, 'status' => 0]);
$this->actingAs($this->admin)
->get(route('admin.access.user.mark', [$this->user, 1]))
->assertSessionHas(['flash_success' => trans('alerts.backend.users.updated')]);
$this->assertDatabaseHas(config('access.users_table'), ['id' => $this->user->id, 'status' => 1]);
Event::assertDispatched(UserDeactivated::class);
Event::assertDispatched(UserReactivated::class);
}
}
<?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());
}
}
......@@ -2,9 +2,85 @@
namespace Tests;
use App\Models\Access\Role\Role;
use App\Models\Access\User\User;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
/**
* @var
*/
protected $admin;
/**
* @var
*/
protected $executive;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $adminRole;
/**
* @var
*/
protected $executiveRole;
/**
* @var
*/
protected $userRole;
public function signIn($user = null)
{
$user = $user ?: create('App\User');
$this->be($user);
return $this;
}
/**
* Set up tests.
*/
public function setUp()
{
parent::setUp();
$this->withoutExceptionHandling();
// 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();
}
}
<?php
namespace Tests\Unit;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}
<?php
namespace Tests\Unit\Models;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use Tests\TestCase;
class BlogCategoryTest extends TestCase
{
/** @test */
public function it_has_a_creator()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class, ['created_by' => access()->id()]);
$this->assertInstanceOf(User::class, $category->creator);
$this->assertEquals($category->creator->id, access()->id());
}
}
<?php
namespace Tests\Unit\Models;
use App\Models\Access\User\User;
use App\Models\BlogTags\BlogTag;
use Tests\TestCase;
class BlogTagTest extends TestCase
{
/** @test */
public function it_has_a_creator()
{
$this->actingAs($this->admin);
$tag = create(BlogTag::class, ['created_by' => access()->id()]);
$this->assertInstanceOf(User::class, $tag->creator);
$this->assertEquals($tag->creator->id, access()->id());
}
}
<?php
namespace Tests\Unit\Models;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use Carbon\Carbon;
use Tests\TestCase;
class BlogTest extends TestCase
{
/** @test */
public function it_has_categories()
{
$this->actingAs($this->admin);
$blog = create(Blog::class, ['created_by' => access()->id()]);
$category = create(BlogCategory::class);
$blog->categories()->sync([$category->id]);
$this->assertInstanceOf(BlogCategory::class, $blog->categories->first());
$this->assertEquals($category->id, $blog->categories->first()->id);
}
/** @test */
public function it_has_tags()
{
$this->actingAs($this->admin);
$blog = create(Blog::class, ['created_by' => access()->id()]);
$tag = create(BlogTag::class);
$blog->tags()->sync([$tag->id]);
$this->assertInstanceOf(BlogTag::class, $blog->tags->first());
$this->assertEquals($tag->id, $blog->tags->first()->id);
}
/** @test */
public function it_has_an_owner()
{
$this->actingAs($this->admin);
$blog = create(Blog::class);
$this->assertInstanceOf(User::class, $blog->owner);
}
/** @test */
public function it_has_a_carbon_date_field_for_publish_datetime()
{
$this->actingAs($this->admin);
$blog = create(Blog::class);
$this->assertInstanceOf(Carbon::class, $blog->publish_datetime);
}
}
<?php
namespace Tests\Unit\Models;
use App\Models\Access\User\User;
use App\Models\Page\Page;
use Tests\TestCase;
class PageTest extends TestCase
{
/** @test */
public function it_has_an_owner()
{
$this->actingAs($this->admin);
$page = create(Page::class);
$this->assertInstanceOf(User::class, $page->owner);
}
}
<?php
namespace Tests\Unit\Models;
use App\Models\Access\Permission\Permission;
use Tests\TestCase;
class PermissionTest extends TestCase
{
/** @test */
public function a_permission_has_roles()
{
$permission = Permission::find(1);
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $permission->roles
);
}
}
<?php
namespace Tests\Unit\Models;
use Tests\TestCase;
class RoleTest extends TestCase
{
/** @test */
public function a_role_has_users()
{
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $this->adminRole->users
);
}
/** @test */
public function a_role_has_permissions()
{
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $this->adminRole->permissions
);
}
}
<?php
namespace Tests\Unit\Models;
use Tests\TestCase;
class UserTest extends TestCase
{
/** @test */
public function a_user_has_a_roles()
{
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $this->admin->roles
);
}
/** @test */
public function a_user_has_a_permissions()
{
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $this->admin->permissions
);
}
/** @test */
public function a_user_has_a_providers()
{
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $this->admin->providers
);
}
/** @test */
public function a_user_has_a_sessions()
{
$this->assertInstanceOf(
'Illuminate\Database\Eloquent\Collection', $this->admin->sessions
);
}
}
<?php
function create($class, $attributes = [], $times = null)
{
return factory($class, $times)->create($attributes);
}
function make($class, $attributes = [], $times = null)
{
return factory($class, $times)->make($attributes);
}
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