Commit f06f5fa4 authored by Viral Solani's avatar Viral Solani

Refactoring User Module

parent 0976330d
......@@ -4,7 +4,7 @@
## Introduction
* This is a laravel Admin Panel, based on [Rappasoft Laravel Boilerplate](https://github.com/rappasoft/laravel-5-boilerplate), with enhancemenets and many modules pre-made, just for you.
* This is a laravel Admin Panel, based on [Rappasoft Laravel Boilerplate](https://github.com/rappasoft/laravel-5-boilerplate/releases/tag/4.5.7), with enhancemenets and many modules pre-made, just for you.
* The project is taken to Laravel 5.5 so we can develop from the latest Laravel.
## Features
......
......@@ -57,8 +57,9 @@ class UserController extends Controller
*/
public function create(CreateUserRequest $request)
{
return view('backend.access.create')
->withRoles($this->roles->getAll());
return view('backend.access.create')->with([
'roles' => $this->roles->getAll()
]);
}
/**
......@@ -93,11 +94,21 @@ class UserController extends Controller
*/
public function edit(User $user, EditUserRequest $request)
{
//@todo move queries in to repositery
$userPermissions = DB::table('permission_user')->where('user_id', $user->id)->pluck('permission_id', 'permission_id')->toArray();
$permissions = DB::table('permissions')->pluck('display_name', 'id')->toArray();
ksort($userPermissions);
ksort($permissions);
/*return view('backend.access.edit')->with([
'user' => $user,
'userRoles' => $user->roles->pluck('id')->all(),
'roles' => $this->roles->getAll(),
'userPermissions' => $userPermissions,
'permissions' => $permissions
]);*/
return view('backend.access.edit', compact('userPermissions', 'permissions'))
->withUser($user)
->withUserRoles($user->roles->pluck('id')->all())
......
......@@ -40,16 +40,11 @@ class User extends Authenticatable
'last_name',
'email',
'password',
'address',
'country_id',
'state_id',
'city_id',
'zip_code',
'ssn',
'status',
'confirmation_code',
'confirmed',
'created_by',
'updated_by'
];
/**
......
var FinBuilders = {
var Backend = {
/**
* Cmspage
*
......@@ -9,7 +9,7 @@ var FinBuilders = {
{
init: function()
{
FinBuilders.tinyMCE.init();
Backend.tinyMCE.init();
},
},
......@@ -51,7 +51,7 @@ var FinBuilders = {
init: function ()
{
this.addHandlers();
FinBuilders.tinyMCE.init();
Backend.tinyMCE.init();
},
addHandlers: function ()
......@@ -115,29 +115,29 @@ var FinBuilders = {
},
emailTemplate: {
selectors: {
emailtemplateSelection: jQuery(".select2")
},
init: function () {
FinBuilders.emailTemplate.addHandlers();
FinBuilders.tinyMCE.init();
Backend.emailTemplate.addHandlers();
Backend.tinyMCE.init();
},
// ! FinBuilders.emailTemplate.addHandlers
// ! Backend.emailTemplate.addHandlers
addHandlers: function () {
// to add placeholder in to active textarea
$("#addPlaceHolder").on('click', function (event) {
FinBuilders.emailTemplate.addPlaceHolder(event);
Backend.emailTemplate.addPlaceHolder(event);
});
$("#showPreview").on('click', function (event) {
FinBuilders.emailTemplate.showPreview(event);
Backend.emailTemplate.showPreview(event);
});
this.selectors.emailtemplateSelection.select2();
},
// ! FinBuilders.emailTemplate.addPlaceHolder
// ! Backend.emailTemplate.addPlaceHolder
addPlaceHolder: function (event) {
var placeHolder = $('#placeHolder').val();
if (placeHolder != '') {
......@@ -145,7 +145,7 @@ var FinBuilders = {
}
},
// ! FinBuilders.emailTemplate.showPreview
// ! Backend.emailTemplate.showPreview
showPreview: function (event) {
jQuery( ".modal-body" ).html(tinyMCE.get('txtBody').getContent());
$(".model-wrapper").modal('show');
......@@ -158,14 +158,14 @@ var FinBuilders = {
*/
Faq:
{
selectors:
selectors:
{
},
init: function ()
{
// this.addHandlers();
FinBuilders.tinyMCE.init();
Backend.tinyMCE.init();
},
addHandlers: function ()
......@@ -198,7 +198,7 @@ var FinBuilders = {
DataTableSearch: {
init: function (dataTable) {
// Header All search columns
$("div.dataTables_filter input").unbind();
$("div.dataTables_filter input").keypress( function (e)
......@@ -210,7 +210,7 @@ var FinBuilders = {
});
// Individual columns search
$('.search-input-text').on( 'keypress', function (e) {
$('.search-input-text').on( 'keypress', function (e) {
// for text boxes
if (e.keyCode == 13)
{
......@@ -221,7 +221,7 @@ var FinBuilders = {
});
// Individual columns search
$('.search-input-select').on( 'change', function (e) {
$('.search-input-select').on( 'change', function (e) {
// for dropdown
var i =$(this).attr('data-column'); // getting column index
var v =$(this).val(); // getting search input value
......@@ -229,13 +229,13 @@ var FinBuilders = {
});
// Individual columns reset
$('.reset-data').on( 'click', function (e) {
$('.reset-data').on( 'click', function (e) {
var textbox = $(this).prev('input'); // Getting closest input field
var i =textbox.attr('data-column'); // Getting column index
$(this).prev('input').val(''); // Blank the serch value
dataTable.api().columns(i).search("").draw();
});
//Copy button
$('#copyButton').click(function(){
$('.copyButton').trigger('click');
......
......@@ -5,6 +5,6 @@
"/css/frontend.css": "/css/frontend.3af0a6cbd7d1d8d042f2a37e97008b7c.css",
"/css/backend.css": "/css/backend.f8550f50504e5b8ef6055285205f223a.css",
"/css/backend-custom.css": "/css/backend-custom.50f14193ab908e3cf471dea6cb6616ae.css",
"/js/backend-custom.js": "/js/backend-custom.d305fff90b4defcf757b268abb9a683c.js",
"/js/backend-custom.js": "/js/backend-custom.76b8496e1c3f25676c8dc7b0f243e416.js",
"/js/dataTable.js": "/js/dataTable.f968d300a6a0b871f138f114361259c8.js"
}
\ No newline at end of file
......@@ -190,7 +190,7 @@
<div id="available-permissions" class="hidden mt-20" style="width: 700px; height: 200px; overflow-x: hidden; overflow-y: scroll;">
<div class="row">
<div class="col-xs-12 get-available-permissions">
</div><!--col-lg-6-->
</div><!--row-->
</div><!--available permissions-->
......@@ -211,45 +211,8 @@
{{ Html::script('js/backend/access/users/script.js') }}
<script type="text/javascript">
$(document).ready(function() {
FinBuilders.Access.init();
//Getting States of default contry
ajaxCall("{{route('admin.get.states')}}");
//Getting Cities of select State
$("#state").on("change", function() {
var stateId = $(this).val();
var url = "{{route('admin.get.cities')}}";
ajaxCall(url, stateId);
});
function ajaxCall(url, data = null)
{
$.ajax({
url: url,
type: "POST",
data: {stateId: data},
success: function(result) {
if(result != null)
{
var options;
$.each(result.data, function(key, value) {
options += "<option value='" + key + "'>" + value + "</option>";
});
if(result.status == "city")
{
$("#city").html('');
$("#city").append(options);
}
else
{
$("#state").append(options);
}
}
}
});
}
Backend.Access.init();
/**
* This function is used to get clicked element role id and return required result
......
......@@ -101,7 +101,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
......@@ -101,7 +101,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
$("body").on("click", "a[name='delete_user_perm']", function(e) {
e.preventDefault();
......
......@@ -161,7 +161,7 @@
<div class="col-xs-12 get-available-permissions">
@if ($permissions)
@foreach ($permissions as $id => $display_name)
<div class="control-group">
<div class="control-group">
<label class="control control--checkbox" for="perm_{{ $id }}">
<input type="checkbox" name="permissions[{{ $id }}]" value="{{ $id }}" id="perm_{{ $id }}" {{ isset($userPermissions[$id]) && in_array($id, $userPermissions) ? 'checked' : '' }} /> <label for="perm_{{ $id }}">{{ $display_name }}</label>
<div class="control__indicator"></div>
......@@ -203,7 +203,7 @@
//Getting States of default contry
ajaxCall("{{route('admin.get.states')}}");
FinBuilders.Access.init();
Backend.Access.init();
//Getting Cities of select State
$("#state").on("change", function() {
......
......@@ -91,7 +91,7 @@
data: {status: 1, trashed: false}
},
columns: [
{data: 'first_name', name: '{{config('access.users_table')}}.first_name'},
{data: 'last_name', name: '{{config('access.users_table')}}.last_name'},
{data: 'email', name: '{{config('access.users_table')}}.email'},
......@@ -115,7 +115,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
......@@ -65,7 +65,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#permissions-table').dataTable({
......@@ -95,9 +95,9 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -68,7 +68,7 @@
{{ Form::input('name', 'ssn', null, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.frontend.register-user.ssn')]) }}
</div><!--col-lg-10-->
</div><!--form-group-->
<div class="form-group">
<div class="col-lg-10 col-md-offset-4">
{{ Form::submit(trans('labels.general.buttons.update'), ['class' => 'btn btn-primary', 'id' => 'update-profile']) }}
......@@ -82,11 +82,11 @@
<script type="text/javascript">
$(document).ready(function() {
FinBuilders.Profile.init();
Backend.Profile.init();
//Getting States of default contry
ajaxCall("{{route('admin.get.states')}}");
//Getting Cities of select State
$("#state").on("change", function() {
......
......@@ -90,7 +90,7 @@
{{ Html::script('js/backend/access/roles/script.js') }}
<script type="text/javascript">
$(document).ready(function() {
FinBuilders.Access.init();
Backend.Access.init();
});
</script>
@endsection
......@@ -82,7 +82,7 @@
{{ Html::script('js/backend/access/roles/script.js') }}
<script type="text/javascript">
$(document).ready(function() {
FinBuilders.Access.init();
Backend.Access.init();
});
</script>
@endsection
\ No newline at end of file
......@@ -67,7 +67,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#roles-table').dataTable({
......@@ -98,7 +98,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -63,7 +63,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#blogcategories-table').dataTable({
......@@ -94,7 +94,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -125,8 +125,8 @@
@section("after-scripts")
<script type="text/javascript">
FinBuilders.Blog.init();
Backend.Blog.init();
//For Blog datetimepicker for publish_datetime
$('#datetimepicker1').datetimepicker();
......
......@@ -65,7 +65,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#blogs-table').dataTable({
......@@ -97,7 +97,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -63,7 +63,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#blogtags-table').dataTable({
......@@ -94,7 +94,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -93,6 +93,6 @@
@endsection
@section("after-scripts")
<script type="text/javascript">
FinBuilders.Cmspage.init();
Backend.Cmspage.init();
</script>
@endsection
......@@ -93,6 +93,6 @@
@endsection
@section("after-scripts")
<script type="text/javascript">
FinBuilders.Cmspage.init();
Backend.Cmspage.init();
</script>
@endsection
\ No newline at end of file
......@@ -57,13 +57,13 @@
<div class="box-body">
{{-- {!! history()->renderType('CMSpage') !!} --}}
</div><!-- /.box-body -->
</div><!--box box-success-->
</div><!--box box-success-->
@endsection
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#cmspages-table').dataTable({
......@@ -94,7 +94,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -107,6 +107,6 @@
@endsection
@section("after-scripts")
<script type="text/javascript">
FinBuilders.emailTemplate.init();
Backend.emailTemplate.init();
</script>
@endsection
\ No newline at end of file
......@@ -10,7 +10,7 @@
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.emailtemplates.management') }}</h3>
<div class="box-tools pull-right">
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
......@@ -81,7 +81,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#emailtemplates-table').dataTable({
......@@ -113,7 +113,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -34,6 +34,6 @@
</div>
@section('after-scripts')
<script type="text/javascript">
FinBuilders.Faq.init();
Backend.Faq.init();
</script>
@endsection
\ No newline at end of file
......@@ -67,7 +67,7 @@
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#faqs-table').dataTable({
......@@ -98,7 +98,7 @@
}
});
FinBuilders.DataTableSearch.init(dataTable);
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
......@@ -86,17 +86,17 @@
{{ Form::input('name', 'ssn', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.frontend.register-user.ssn')]) }}
</div><!--col-md-6-->
</div><!--form-group-->
<div class="form-group">
<div class="col-xs-7">
<label class="col-md-12 control-label">
{!! Form::checkbox('is_term_accept',1,false) !!}
I accept {!! link_to_route('frontend.cmspages.show', trans('validation.attributes.frontend.register-user.terms_and_conditions').'*', ['page_slug'=>'terms-and-conditions']) !!} </label>
</div><!--form-group-->
</div><!--col-md-6-->
......@@ -135,8 +135,8 @@
$(document).ready(function() {
// To Use Select2
FinBuilders.Select2.init();
Backend.Select2.init();
//Getting States of default contry
ajaxCall("{{route('frontend.get.states')}}");
......
......@@ -66,8 +66,8 @@
$(document).ready(function() {
// To Use Select2
FinBuilders.Select2.init();
Backend.Select2.init();
if($.session.get("tab") == "edit")
{
$("#li-password").removeClass("active");
......@@ -92,7 +92,7 @@
//Getting States of default contry
ajaxCall("{{route('frontend.get.states')}}");
//Getting Cities of select State
$("#state").on("change", function() {
......
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