Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop
    1. Home
    2. hashan
    • Profile
    • Following 1
    • Followers 0
    • Topics 8
    • Posts 20
    • Best 5
    • Controversial 0
    • Groups 3

    hashan

    @hashan

    Web Development

    Technology Enthusiast

    6
    Reputation
    338
    Profile views
    20
    Posts
    0
    Followers
    1
    Following
    Joined Last Online

    hashan Unfollow Follow
    Node.js Web Development Linux Help

    Best posts made by hashan

    • How to fetch realtime Data from firebase ?

      Firebase realtime database එකකින් data ගන්නෙ කොහොමද අපිට custom dashboard එහෙක පෙන්නන්න පුලුවන් විදිහට.. charts වලට එහෙම.

      posted in General Discussion
      hashan
      hashan
    • What is the best javascript framework to learn?

      What is the best javascript framework to learn? What is popular in sri lanka? Ex: Codgen uses Angular for their frontend development.

      posted in Front-End Development
      hashan
      hashan
    • RE: List of Web Development (JS) Resources You Should Know About...

      Thanks bro well done

      posted in Web Development
      hashan
      hashan
    • can not run migration
      public function up()
      {
          Schema::create('registerusers', function (Blueprint $table) {
              $table->increments('id');
              $table->string('firstname', 10);
              $table->string('lastname', 20);
              $table->integer('phone', 10);
              $table->string('email')->unique();
              $table->string('gender');
              $table->string('vehiclemodel');
              $table->string('platenum', 6);
              $table->timestamps();
          });
      }
      

      Erroris : Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

      posted in Back-End Development
      hashan
      hashan
    • Laravel Data Save Error SQLSTATE[HY000]: General error: 1364

      SQLSTATE[HY000]: General error: 1364 Field 'username' doesn't have a default value (SQL: insert into registerusers (updated_at, created_at) values (2019-07-15 12:03:06, 2019-07-15 12:03:06))
      menna me error eka enwa, data base ekata data sav krnna giama.

      public function storeRegister(Request $request)
      {
      $registeruser = new registeruser;
      $request->all();
      $registeruser->save();
      }

      posted in Back-End Development
      hashan
      hashan

    Latest posts made by hashan

    • RE: COVID19 Virtual Assistant Sri Lanka ...

      @cody Great!

      posted in Announcements
      hashan
      hashan
    • RE: Laravel 5.8 Auth::guard($guard)->check() always return false

      @ciaompe yh i checked. it returns the correct guard value

      posted in Laravel Framework
      hashan
      hashan
    • Laravel 5.8 Auth::guard($guard)->check() always return false

      I have two separate logins using guards which customer & adminuser. I have checkRole middleware for adminuser login and it works perfectly. I used guest middleware (RedirectifAuthenticated) to customer login. When customer login check with Auth::guard($guard)->check() it always returns false. But Auth::guard('customer')->attempt returns true. I can't find a solution.

      here is the login controller for customer

      class LoginController extends Controller
      {
      
          use AuthenticatesUsers;
      
          public function __construct()
          {
             $this->middleware('guest:customer')->except('customerlogout');
          }
      
          //login the customer
          public function customerLogin(Request $request)
          {
              $email = $request->get('email');
              $password = $request->get('password');
              
              
              //Getting user inputs and authenticate the customer
              $status = Auth::guard('customer')->attempt([
                  'email' => $email, 
                  'password' => $password ] 
                  );
      
              //Check login  
              if ($status) {
                  //if login pass,redirect to customer account page
                  return redirect()->intended('/customer_account');
                  
               }else{
                   //if login fail,redirect back to home page
                   return redirect()->back();
               }
          }
          
          //logout the customer
          public function customerlogout(Request $request)
          {   
              Auth::guard('customer')->logout();
              $request->session()->flush();
              return redirect('/index');   
          }
      }
      

      here is the guest middleware

          public function handle($request, Closure $next, $guard = null)
          {       
              if ($guard === "customer" && Auth::guard($guard)->check()) {
                  return redirect('/customer_account');
              }
              if (!Auth::guard($guard)->check()) {
                  return redirect('/index');
              }
              return $next($request);
          }
      

      Any help is appreciated, thanks!

      posted in Laravel Framework
      hashan
      hashan
    • RE: Laravel Multiple Authentication using guards, not working!

      @root any answer?

      posted in Back-End Development
      hashan
      hashan
    • Laravel Multiple Authentication using guards, not working!

      laravel framework එක හොඳට දන්න කෙනෙක් උදව් කරන්න. customers ලටයි Admin users ලටයි වෙන වෙනම guards දෙකක් හඳල තියෙන්නෙ. ඒත් attempt method එකෙන් හරියට login එක වෙලා redirect වෙන්නෙ නැ.

      මේ Logincontroller එක
      dd($status) එකෙනුත් false රිටන් වෙන්නෙ.

      <?php
      
      namespace App\Http\Controllers\Auth;
      
      use App\Http\Controllers\Controller;
      use Illuminate\Foundation\Auth\AuthenticatesUsers;
      use Illuminate\Http\Request;
      use Auth;
      
      class LoginController extends Controller
      {
          /*
          |--------------------------------------------------------------------------
          | Login Controller
          |--------------------------------------------------------------------------
          |
          | This controller handles authenticating users for the application and
          | redirecting them to your home screen. The controller uses a trait
          | to conveniently provide its functionality to your applications.
          |
          */
      
          use AuthenticatesUsers;
      
          /**
           * Where to redirect users after login.
           *
           * @var string
           */
          protected $redirectTo = '/home';
      
          /**
           * Create a new controller instance.
           *
           * @return void
           */
          public function __construct()
          {
              $this->middleware('guest')->except('logout');
              $this->middleware('guest:adminuser')->except('logout');
              $this->middleware('guest:customer')->except('logout');
          }
          
          /*public function showUserLoginForm() //show backend login form for admin users
          {
              return view('auth.login', ['url' => 'admin']); //edit this line to set path for adminLTE login form
          }*/
      
          public function adminLogin()
          {
              return view('admin.adminLogin');
          }
      
          public function adminHome()
          {
              return view('admin.home');
          }
      
          //login for the Admin user
          public function userLogin(Request $request)
          {
              $this->validate($request, [
                  'username'   => 'required|min:3',
                  'password' => 'required|min:6|max:6'
              ]);
      
              $status = Auth::guard('adminuser')->attempt(['email' => $request->username, 'password' => $request->password]);
              dd($status);
              if ($status == true) {
                  return redirect()->intended('/adminhome');
                  //$request->session()->flash('success', 'Login Successfully!');
                 // return redirect('/adminhome'); // redirect to admin dashboard
              }
              else{
                  $request->session()->flash('error', 'Sorry,Login Unuccessfull!');
                  return redirect()->back();
              }
              //return back()->withInput($request->only('email', 'remember'));
          }
      
      
          //login for the customer
          public function customerLogin(Request $request)
          {
              $this->validate($request, [
                  'username' => 'required|min:3',
                  'password' => 'required|min:6|max:6'
              ]);
              
              $status = Auth::guard('customer')->attempt(['email' => $request->username, 'password' => $request->password], $request->get('remember'));
              if ($status == true) {
                  $request->session()->flash('success', 'Login Successfully!');
                  return redirect('/index');
              }
              else{
                  $request->session()->flash('error', 'Sorry,Login Unuccessfull!');
                  return redirect()->back();
              }
              //return back()->withInput($request->only('email', 'remember'));
          }
      }
      
      

      AdminUser.php Model එක

      <?php
      
      namespace App\Models;
      
      use Illuminate\Database\Eloquent\Model;
      use Illuminate\Notifications\Notifiable;
      use Illuminate\Foundation\Auth\User as Authenticatable;
      
      class AdminUser extends Authenticatable
      {
          protected $table = 'adminusers';
      
          use Notifiable;
      
          protected $guard = 'adminuser';
      
          protected $fillable = [
              'username', 'password',
          ];
      
          protected $hidden = [
              'password', 'remember_token',
          ];
      }
      
      

      auth.php මේකෙ තමා customer , adminuser කියන guards දෙක හදල තියෙන්නෙ

      <?php
      
      return [
      
          /*
          |--------------------------------------------------------------------------
          | Authentication Defaults
          |--------------------------------------------------------------------------
          |
          | This option controls the default authentication "guard" and password
          | reset options for your application. You may change these defaults
          | as required, but they're a perfect start for most applications.
          |
          */
      
          'defaults' => [
              'guard' => 'web',
              'passwords' => 'users',
          ],
      
          /*
          |--------------------------------------------------------------------------
          | Authentication Guards
          |--------------------------------------------------------------------------
          |
          | Next, you may define every authentication guard for your application.
          | Of course, a great default configuration has been defined for you
          | here which uses session storage and the Eloquent user provider.
          |
          | All authentication drivers have a user provider. This defines how the
          | users are actually retrieved out of your database or other storage
          | mechanisms used by this application to persist your user's data.
          |
          | Supported: "session", "token"
          |
          */
      
          'guards' => [
              'web' => [
                  'driver' => 'session',
                  'provider' => 'users',
              ],
      
              'api' => [
                  'driver' => 'token',
                  'provider' => 'users',
                  'hash' => false,
              ],
              'customer' => [
                  'driver' => 'session',
                  'provider' => 'customers',
              ],
              'adminuser' => [
                  'driver' => 'session',
                  'provider' => 'adminusers',
              ],
          ],
      
          /*
          |--------------------------------------------------------------------------
          | User Providers
          |--------------------------------------------------------------------------
          |
          | All authentication drivers have a user provider. This defines how the
          | users are actually retrieved out of your database or other storage
          | mechanisms used by this application to persist your user's data.
          |
          | If you have multiple user tables or models you may configure multiple
          | sources which represent each model / table. These sources may then
          | be assigned to any extra authentication guards you have defined.
          |
          | Supported: "database", "eloquent"
          |
          */
      
          'providers' => [
              'users' => [
                  'driver' => 'eloquent',
                  'model' => App\Models\User::class,
              ],
              'customers' => [
                  'driver' => 'eloquent',
                  'model' => App\Models\Customer::class,
              ],
              'adminusers' => [
                  'driver' => 'eloquent',
                  'model' => App\Models\AdminUser::class, 
              ],
      
              // 'users' => [
              //     'driver' => 'database',
              //     'table' => 'users',
              // ],
          ],
      
          /*
          |--------------------------------------------------------------------------
          | Resetting Passwords
          |--------------------------------------------------------------------------
          |
          | You may specify multiple password reset configurations if you have more
          | than one user table or model in the application and you want to have
          | separate password reset settings based on the specific user types.
          |
          | The expire time is the number of minutes that the reset token should be
          | considered valid. This security feature keeps tokens short-lived so
          | they have less time to be guessed. You may change this as needed.
          |
          */
      
          'passwords' => [
              'users' => [
                  'provider' => 'users',
                  'table' => 'password_resets',
                  'expire' => 60,
              ],
          ],
      
      ];
      
      

      Adminuser login form එක

       <form action="/adminUserLogin" method="POST">
              @csrf
              <div class="input-group mb-3">
                <input type="text" class="form-control" placeholder="Username" name="username" id="username">
                <div class="input-group-append">
                    <span class="fa fa-user input-group-text"></span>
                </div>
              </div>
              <div class="input-group mb-3">
                <input type="password" class="form-control" placeholder="Password" name="password" id="password">
                <div class="input-group-append">
                    <span class="fa fa-lock input-group-text"></span>
                </div>
              </div>
              <div class="row">
                <div class="col-8">
                  <div class="checkbox icheck">
                    <label>
                      <input type="checkbox"> Remember Me
                    </label>
                  </div>
                </div>
                <!-- /.col -->
                <div class="col-4">
                  <button type="submit" class="btn btn-primary btn-block">Sign In</button>
                </div>
                <!-- /.col -->
              </div>
            </form>
      

      කොහොමද මේක හදාගන්නෙ. plz help!

      posted in Back-End Development
      hashan
      hashan
    • RE: Number predict javascript

      i know about ML bro, but for my project expect a own work, without libraries or frameworks. i found a javascript library called brain.js ; it is vey easy than tensorflow.js; this problem can easily solve with it. but i wish a simple algorithm for this only with js. according to the situation i will use brain.js instead of my own algorithm.
      thanks.

      posted in General Discussion
      hashan
      hashan
    • Number predict javascript

      I want to predict the next number by analysing a array of random number sequence in javascript without libraries. How can i do this ?
      Ex : array = [ 27, 35, 19 ,7 ,59, 45 ] what number is next?

      posted in General Discussion
      hashan
      hashan
    • Laravel Data Save Error SQLSTATE[HY000]: General error: 1364

      SQLSTATE[HY000]: General error: 1364 Field 'username' doesn't have a default value (SQL: insert into registerusers (updated_at, created_at) values (2019-07-15 12:03:06, 2019-07-15 12:03:06))
      menna me error eka enwa, data base ekata data sav krnna giama.

      public function storeRegister(Request $request)
      {
      $registeruser = new registeruser;
      $request->all();
      $registeruser->save();
      }

      posted in Back-End Development
      hashan
      hashan
    • RE: can not run migration

      SQLSTATE[HY000]: General error: 1364 Field 'username' doesn't have a default value (SQL: insert into registerusers (updated_at, created_at) values (2019-07-15 12:03:06, 2019-07-15 12:03:06))
      menna me error eka enwa, data base ekata data sav krnna giama.

      public function storeRegister(Request $request)
      {
      $registeruser = new registeruser;
      $request->all();
      $registeruser->save();
      }

      posted in Back-End Development
      hashan
      hashan
    • can not run migration
      public function up()
      {
          Schema::create('registerusers', function (Blueprint $table) {
              $table->increments('id');
              $table->string('firstname', 10);
              $table->string('lastname', 20);
              $table->integer('phone', 10);
              $table->string('email')->unique();
              $table->string('gender');
              $table->string('vehiclemodel');
              $table->string('platenum', 6);
              $table->timestamps();
          });
      }
      

      Erroris : Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

      posted in Back-End Development
      hashan
      hashan