added enable option
This commit is contained in:
parent
495ba7eb70
commit
cd909d909e
@ -49,14 +49,28 @@ class Login extends Controller
|
||||
|
||||
public function store()
|
||||
{
|
||||
// Attempt to login
|
||||
if (!auth()->attempt(request(['email', 'password']))) {
|
||||
flash('Please check your credentials and try again.')->error();
|
||||
flash(trans('auth.failed'))->error();
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
if (auth()->user()->customer) {
|
||||
return redirect('/customers');
|
||||
// Get user object
|
||||
$user = auth()->user();
|
||||
|
||||
// Check if user is enabled
|
||||
if (!$user->enabled) {
|
||||
auth()->logout();
|
||||
|
||||
flash(trans('auth.disabled'))->error();
|
||||
|
||||
return redirect('auth/login');
|
||||
}
|
||||
|
||||
// Check if is customer
|
||||
if ($user->customer) {
|
||||
return redirect('customers');
|
||||
}
|
||||
|
||||
return redirect('/');
|
||||
|
@ -17,11 +17,7 @@ use Route;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use LaratrustUserTrait;
|
||||
use Notifiable;
|
||||
use SoftDeletes;
|
||||
use Filterable;
|
||||
use Sortable;
|
||||
use Filterable, LaratrustUserTrait, Notifiable, SoftDeletes, Sortable;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
@ -30,7 +26,7 @@ class User extends Authenticatable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'email', 'password', 'locale', 'picture'];
|
||||
protected $fillable = ['name', 'email', 'password', 'locale', 'picture', 'enabled'];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
@ -46,6 +42,13 @@ class User extends Authenticatable
|
||||
*/
|
||||
protected $dates = ['last_logged_in_at', 'created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sortable = ['name', 'email', 'enabled'];
|
||||
|
||||
public function companies()
|
||||
{
|
||||
return $this->morphToMany('App\Models\Company\Company', 'user', 'user_companies', 'user_id', 'company_id');
|
||||
@ -178,4 +181,15 @@ class User extends Authenticatable
|
||||
|
||||
return $this->filter($input)->sortable($sort)->paginate($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to only include active currencies.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeEnabled($query)
|
||||
{
|
||||
return $query->where('enabled', 1);
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,6 @@
|
||||
namespace App\Models\Setting;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Expense\Payment;
|
||||
use App\Models\Income\Revenue;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ class CreateCompaniesTable extends Migration
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('domain');
|
||||
$table->boolean('enabled')->default(0);
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ return [
|
||||
],
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'disabled' => 'This account is disabled. Please, contact the system administrator.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
];
|
||||
|
@ -27,6 +27,8 @@
|
||||
@permission('read-auth-roles')
|
||||
{{ Form::checkboxGroup('roles', trans_choice('general.roles', 2), $roles, 'display_name') }}
|
||||
@endpermission
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled')) }}
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
|
||||
@ -50,6 +52,9 @@
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var text_yes = '{{ trans('general.yes') }}';
|
||||
var text_no = '{{ trans('general.no') }}';
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#locale").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.languages', 1)]) }}"
|
||||
@ -61,7 +66,7 @@
|
||||
placeholder : '{{ trans('general.form.no_file_selected') }}'
|
||||
});
|
||||
|
||||
$('input').iCheck({
|
||||
$('input[type=checkbox]').iCheck({
|
||||
checkboxClass: 'icheckbox_square-green',
|
||||
radioClass: 'iradio_square-green',
|
||||
increaseArea: '20%' // optional
|
||||
|
@ -32,6 +32,8 @@
|
||||
@permission('read-auth-roles')
|
||||
{{ Form::checkboxGroup('roles', trans_choice('general.roles', 2), $roles, 'display_name') }}
|
||||
@endpermission
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled')) }}
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
|
||||
@ -58,6 +60,9 @@
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var text_yes = '{{ trans('general.yes') }}';
|
||||
var text_no = '{{ trans('general.no') }}';
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#locale").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.languages', 1)]) }}"
|
||||
@ -69,7 +74,7 @@
|
||||
placeholder : '<?php echo $user->picture; ?>'
|
||||
});
|
||||
|
||||
$('input').iCheck({
|
||||
$('input[type=checkbox]').iCheck({
|
||||
checkboxClass: 'icheckbox_square-green',
|
||||
radioClass: 'iradio_square-green',
|
||||
increaseArea: '20%' // optional
|
||||
|
@ -11,16 +11,16 @@
|
||||
@section('content')
|
||||
<!-- Default box -->
|
||||
<div class="box box-success">
|
||||
<div class="box-header">
|
||||
<div class="box-header with-border">
|
||||
{!! Form::open(['url' => 'auth/users', 'role' => 'form', 'method' => 'GET']) !!}
|
||||
<div class="pull-left">
|
||||
<span class="title-filter">{{ trans('general.search') }}:</span>
|
||||
<span class="title-filter hidden-xs">{{ trans('general.search') }}:</span>
|
||||
{!! Form::text('search', request('search'), ['class' => 'form-control input-filter input-sm', 'placeholder' => trans('general.search_placeholder')]) !!}
|
||||
{!! Form::select('role', $roles, request('role'), ['class' => 'form-control input-filter input-sm']) !!}
|
||||
{!! Form::button('<span class="fa fa-filter"></span> ' . trans('general.filter'), ['type' => 'submit', 'class' => 'btn btn-sm btn-default btn-filter']) !!}
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<span class="title-filter">{{ trans('general.show') }}:</span>
|
||||
<span class="title-filter hidden-xs">{{ trans('general.show') }}:</span>
|
||||
{!! Form::select('limit', $limits, request('limit', setting('general.list_limit', '25')), ['class' => 'form-control input-filter input-sm', 'onchange' => 'this.form.submit()']) !!}
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
@ -28,30 +28,52 @@
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<div class="table table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover" id="tbl-users">
|
||||
<table class="table table-striped table-hover" id="tbl-users">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@sortablelink('name', trans('general.name'))</th>
|
||||
<th>@sortablelink('email', trans('general.email'))</th>
|
||||
<th>@sortablelink('roles', trans_choice('general.roles', 2))</th>
|
||||
<th style="width: 15%;">{{ trans('general.actions') }}</th>
|
||||
<th class="col-md-3">@sortablelink('name', trans('general.name'))</th>
|
||||
<th class="col-md-3">@sortablelink('email', trans('general.email'))</th>
|
||||
<th class="col-md-3 hidden-xs">{{ trans_choice('general.roles', 2) }}</th>
|
||||
<th class="col-md-1 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
||||
<th class="col-md-1">{{ trans('general.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($users as $item)
|
||||
<tr>
|
||||
<td><a href="{{ url('auth/users/' . $item->id . '/edit') }}"><img src="{{ Storage::url($item->picture) }}" class="users-image" alt="{{ $item->name }}" title="{{ $item->name }}"> {{ $item->name }}</a></td>
|
||||
<td>
|
||||
<a href="{{ url('auth/users/' . $item->id . '/edit') }}">
|
||||
@if ($item->picture)
|
||||
<img src="{{ Storage::url($item->picture) }}" class="users-image" alt="{{ $item->name }}" title="{{ $item->name }}">
|
||||
@endif
|
||||
{{ $item->name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $item->email }}</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<td class="hidden-xs" style="vertical-align: middle;">
|
||||
@foreach($item->roles as $role)
|
||||
<label class="label label-default">{{ $role->display_name }}</label>
|
||||
@endforeach
|
||||
</td>
|
||||
<td class="hidden-xs">
|
||||
@if ($item->enabled)
|
||||
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
||||
@else
|
||||
<span class="label label-danger">{{ trans('general.disabled') }}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ url('auth/users/' . $item->id . '/edit') }}" class="btn btn-primary btn-xs"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {{ trans('general.edit') }}</a>
|
||||
@permission('delete-auth-users')
|
||||
{!! Form::deleteButton($item, 'auth/users') !!}
|
||||
@endpermission
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">
|
||||
<i class="fa fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li><a href="{{ url('auth/users/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
|
||||
@permission('delete-auth-users')
|
||||
<li>{!! Form::deleteLink($item, 'auth/users') !!}</li>
|
||||
@endpermission
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
@ -18,6 +18,8 @@
|
||||
{{ Form::textareaGroup('company_address', trans('general.address')) }}
|
||||
|
||||
{{ Form::fileGroup('company_logo', trans('companies.logo')) }}
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled')) }}
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
|
||||
@ -40,6 +42,9 @@
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var text_yes = '{{ trans('general.yes') }}';
|
||||
var text_no = '{{ trans('general.no') }}';
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#default_currency").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
|
||||
|
@ -24,6 +24,8 @@
|
||||
{{ Form::textareaGroup('company_address', trans('general.address')) }}
|
||||
|
||||
{{ Form::fileGroup('company_logo', trans('companies.logo')) }}
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled')) }}
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
|
||||
@ -48,6 +50,9 @@
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var text_yes = '{{ trans('general.yes') }}';
|
||||
var text_no = '{{ trans('general.no') }}';
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#default_currency").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
|
||||
|
@ -33,10 +33,11 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-md-1 hidden-xs">@sortablelink('id', trans('general.id'))</th>
|
||||
<th class="col-md-4">@sortablelink('name', trans('general.name'))</th>
|
||||
<th class="col-md-3">@sortablelink('name', trans('general.name'))</th>
|
||||
<th class="col-md-2 hidden-xs">@sortablelink('domain', trans('companies.domain'))</th>
|
||||
<th class="col-md-2 hidden-xs">@sortablelink('email', trans('general.email'))</th>
|
||||
<th class="col-md-2 hidden-xs">@sortablelink('created_at', trans('general.created'))</th>
|
||||
<th class="col-md-1 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
||||
<th class="col-md-1">{{ trans('general.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -48,6 +49,13 @@
|
||||
<td class="hidden-xs">{{ $item->domain }}</td>
|
||||
<td class="hidden-xs">{{ $item->company_email }}</td>
|
||||
<td class="hidden-xs">{{ Date::parse($item->created_at)->format($date_format) }}</td>
|
||||
<td>
|
||||
@if ($item->enabled)
|
||||
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
||||
@else
|
||||
<span class="label label-danger">{{ trans('general.disabled') }}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">
|
||||
|
Loading…
x
Reference in New Issue
Block a user