added enable option
This commit is contained in:
		@@ -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
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user