shrutiupari

shrutiupari

Member Since 11 Months Ago

Experience Points 470
Experience Level 1

4,530 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

06 Aug
2 weeks ago

shrutiupari left a reply on How To Show 2 Tables Data In Calendar?

Can anyone please help me?

05 Aug
2 weeks ago

shrutiupari left a reply on How To Show 2 Tables Data In Calendar?

Reports Model is as follows:

`<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Reports extends Model { protected $table = 'travel_details'; } ?> `

shrutiupari started a new conversation How To Show 2 Tables Data In Calendar?

I have written MySQL View as follows:

CREATE ALGORITHM = UNDEFINED DEFINER =root@localhostSQL SECURITY DEFINER VIEWtravel_db.travel_detailsAS SELECT DISTINCTtravel_db.leaves.idASid,travel_db.trips.idAStripid,travel_db.leaves.leave_idASleave_id,travel_db.trips.trip_idAStrip_idFROM (travel_db.leavesJOINtravel_db.trips) WHERE (travel_db.leaves.tgi_id=travel_db.trips.tgi_id)

Now I want to show these records in calendar format. I am getting the response correct but unable to view that data in Calendar. Can anybody help me? The below code is what I am running to view the data:

`$reports = Reports::all();

    $data = array();
    foreach($reports as $rows) {
        $data[]=array(
            'id'=>$rows['id'],
            'leave_id'=>$rows['leave_id'],
            'type'=>$rows['tgi_id'],
            'start'=>$rows['from_date'],
            'end'=>$rows['to_date'],
            'title'=>$rows['reason']
            );
    }      
    
     return response()->json($data); `
27 Jun
1 month ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

@MUNAZZIL - the code that I have written is it write? As I am able to print all the data but when trying to login its not redirecting to home page rather its going to login page i.e., 302 error(redirection)

shrutiupari left a reply on Laravel Login Using Id From Different Database

@ALIYA - config/database.php

<?php

use Illuminate\Support\Str;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'travel_db'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

        'mysql_external' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_EXT_DATABASE', 'tools'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => env('REDIS_CLIENT', 'predis'),

        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'predis'),
            'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
        ],

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_DB', 0),
        ],

        'cache' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_CACHE_DB', 1),
        ],

    ],

];

env file

APP_NAME=Travel
APP_ENV=local
APP_KEY=base64:TXPUwJZ0RiI9DvXaYebeJ5Bqegnn+ZSKTBd0SlmYd9E=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost:8000/

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=travel_db
DB_USERNAME=root
DB_PASSWORD=

DB_CONNECTION=mysql_external
DB_HOST=127.0.0.1
DB_PORT=3306
DB_EXT_DATABASE=tools_bta
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

auth/login.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Login</div>

                <div class="panel-body">
                    <form class="form-horizontal" method="POST" action="{{ route('login.custom') }}">
                        {{ csrf_field() }}

                        <!-- <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div> -->

                        <div class="form-group{{ $errors->has('tgi') ? ' has-error' : '' }}">
                            <label for="tgi" class="col-md-4 control-label">Employee TGI</label>

                            <div class="col-md-6">
                                <input id="tgi" type="text" class="form-control" name="tgi" value="{{ old('tgi') }}" required autofocus>

                                @if ($errors->has('tgi'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('tgi') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">Password</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-8 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    Login
                                </button>

                                <a class="btn btn-link" href="{{ route('password.request') }}">
                                    Forgot Your Password?
                                </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

User.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    protected $connection = 'mysql';

    protected $table = 'users';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'tgi' , 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

MasterUser.php(another model file for external connection)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\User;

class MasterUser extends Model
{
    //
    protected $connection = 'mysql_external';
    
    protected $table = 'emp_username';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'emp_id', 'tgi' , 'pass',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'pass', 
    ];

    public function employee() {
        return $this->belongsTo(App\User::class);
    }
}

config/auth.php

<?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,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | 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\User::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,
        ],
    ],

];

app/Http/Controllers/LoginController.php

Its the file which I have posted above
26 Jun
1 month ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

@ALIYA - It's not at all redirecting to home page, instead redirecting back to login page. I am able to see the data from another database's table but it's not logging in instead going back to login.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class LoginController extends Controller
{
    //
    public function login(Request $request) {
        // dd($request->all());
        $input = $request->all();
        $legonDB = \DB::connection('mysql_external');
        $logindata = $legonDB->table('emp_username_db')->select('tgi')->where('tgi', '=', $input['tgi'])->get();
        print_r($logindata);
}

shrutiupari left a reply on Laravel Login Using Id From Different Database

@ALIYA - I did that but not getting any success.

shrutiupari left a reply on Laravel Login Using Id From Different Database

I am trying to login using emp id and password which is in another database table. I am still facing issues.

13 Jun
2 months ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreateUserRequest;
use UxWeb\SweetAlert;
use App\LegonUser;
use Request;
use Alert;
use DB;

class LegonUserController extends Controller
{
    //
    public function index()
    {
        # code...
        return view('login');
    }

    public function LegonSignin() {
    $input = Request::all();
          $user_data = [
          'tgi' => $input['tgi'],
          'pass' => $input['pass']
        ];

    //$database = LegonUser::on('mysql2')->select('*')->where($user_data ,'=',         $user_data)->get();
    $legonModel = new LegonUser;
    $legonDB = \DB::connection('mysql_external');
    $logindata = $legonDB->table('emp_username_db')->select('tgi', 'pass', 'emp_id')->where('tgi', '=', $input['tgi'])->get();

        if ($logindata) {
            print_r($logindata);
            // return redirect('/');
           }else {
            return redirect()->back()->withErrors($user_data);
          }
        
   
}

    public function getTest()
    {
        $db_ext = \DB::connection('mysql_external');
        $countries = $db_ext->table('emp_username_db')->select('tgi', 'pass')->get();
        print_r($countries);
    }

} 

HomeController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('/home');
    }
}

I have done changes in config/database.php and config/auth.php as suggested in this https://laracasts.com/discuss/channels/eloquent/laravel-5-multiple-database-connection link. The login.blade.php remains the same but with different values passed as shown in the LegonUserController.php.

shrutiupari left a reply on Laravel Login Using Id From Different Database

I will show the Entire code you can check it. User.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    protected $connection = 'mysql_external';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $primaryKey = 'id';
    protected $fillable = [
        'id', 'emp_id', 'tgi', 'pass',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'pass',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */    
}
 
LegonUser.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable; 
use Illuminate\Auth\Passwords\CanResetPassword; 
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; 
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class LegonUser extends Model implements AuthenticatableContract, CanResetPasswordContract 
{ 
    use Authenticatable, CanResetPassword;

    //
     /**
     * The database name used by the model.
     *
     * @var string
     */
    protected $connection = 'mysql_external';
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'emp_username_db';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['emp_id', 'tgi', 'pass'];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['pass'];

    public function user() {
        return $this->belongsTo('App\User','tgi','tgi');
    }
}

shrutiupari left a reply on Laravel Login Using Id From Different Database

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreateUserRequest;
use UxWeb\SweetAlert;
use App\LegonUser;
use Request;
use Alert;
use DB;

class LegonUserController extends Controller
{
    //
    public function index()
    {
        # code...
        return view('login');
    }

  public function LegonSignin() {
    $input = Request::all();
          

    //$database = LegonUser::on('mysql2')->select('*')->where($user_data ,'=',         $user_data)->get();
    $legonModel = new LegonUser;
    $legonDB = \DB::connection('mysql_external');
    $logindata = $legonDB->table('emp_username_db')->get();

    $user_data = array(
          'tgi' => $input['tgi'],
          'pass' => $input['pass']
        );

    if (Auth::attempt($user_data)) {
        print_r($user_data);
        // return redirect('/');
       }else {
        return redirect()->back()->withErrors($user_data);
      }
        
   
}

shrutiupari left a reply on Laravel Login Using Id From Different Database

Hi All, So far this what is did using this link https://laracasts.com/discuss/channels/eloquent/laravel-5-multiple-database-connection, I am able to get the data but its not validating.The Controller file:

12 Jun
2 months ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

I changed but still no luck

shrutiupari left a reply on Laravel 5 Multiple Database Connection.

I tried in a similar way but still no luck. Please help

07 Jun
2 months ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

Its showing error saying please fill in the details.

shrutiupari left a reply on Laravel Login Using Id From Different Database

I did in a similar fashion as its done for normal login. Only difference is that I created separate controller and wrote the above functions. I tried to fetch data from 2 databases only if they match and show in datatables, which is working completely fine.

shrutiupari left a reply on Laravel Login Using Id From Different Database

namespace App\Http\Controllers;

use Illuminate\Http\Request; use DB; use Auth; use App\Model\User; use App\Models\EmployeeMaster;

class AppController extends Controller { // public function __construct() {

}

public function showLoginForm(){

    return view('employeelogin');
}

public function masterlogin(Request $request) {
    
    $this->validate($request,[
        'tgi' => 'required|tgi|exists:tools_bta.emp_username_db',
        'pass' => 'required|pass|exists:tools_bta.emp_username_db',
    ]);

    if(EmployeeMaster::attempt(['tgi' => $request->tgi, 'pass' => $request->pass])){
        return "Logged in successfully";
    }else{
        return "Something went wrong";
    }
}

}

shrutiupari left a reply on Laravel Login Using Id From Different Database

@MUNAZZIL - I have done everything. Still I dont know why is it not logging

shrutiupari left a reply on Laravel Login Using Id From Different Database

@SIANGBOON - Yes it does. I mean both id and password exist in the second database

06 Jun
2 months ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

@MUNAZZIL - <?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; use DB;

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');
}

}

shrutiupari left a reply on Laravel Login Using Id From Different Database

@SERGIU17 - It should be other database table. Thanks I will check the video and let you know.

shrutiupari left a reply on Laravel Login Using Id From Different Database

{{ __('Login') }}
            <div class="card-body">
                <form method="POST" action="{{ route('employeelogin') }}">
                    @csrf

                    <div class="form-group row">
                        <label for="tgi" class="col-sm-4 col-form-label text-md-right">{{ __('Emp TGI') }}</label>
                        <div class="col-md-6">
                            <input id="TGI" type="text" class="form-control{{ $errors->has('TGI') ? ' is-invalid' : '' }}" name="TGI" value="{{ old('TGI') }}" required autofocus>

                            @if ($errors->has('TGI'))
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $errors->first('TGI') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="Password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                        <div class="col-md-6">
                            <input id="Password" type="Password" class="form-control{{ $errors->has('Password') ? ' is-invalid' : '' }}" name="Password" required>

                            @if ($errors->has('Password'))
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $errors->first('Password') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group row mb-0">
                        <div class="col-md-8 offset-md-4">
                            <button type="submit" class="btn btn-primary">
                                {{ __('Login') }}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

The view file

shrutiupari left a reply on Laravel Login Using Id From Different Database

Yes I have done it. But not getting how to and where to do the changes. I have created separate login page and then I am confused as to where should I write the query such that I must be able to login only if user exists in the other database.

shrutiupari started a new conversation Laravel Login Using Id From Different Database

I have so far changed the config/database.php file and even the .env file and set it to my 2 of the databases. But I am not able to login using the id. Can anybody please help me.

12 Sep
11 months ago

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

@Snapey I want to insert only if the student has filled the form and whose status is "Applied/Mail Send". If there is no such application form filled by him then student should not be created.

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

@jlrdw I am able to add student even after checking status. I need to check whether status is "Applied" or "Mail Send" for that particular student.

11 Sep
11 months ago

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

I did check in such way as you can see in the above query using where query

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

I have a table "Applications" where 'status' are applied, pending. So I want to create students only if (s)he has applied the application form and its status is "applied".

$appStatus = Applications::where('status', 'Applied')->orWhere('status', 'Mail Send')->first(); if($appStatus){ $status = Student::create($input + ['student_id'=>$id,'school_id'=> $this->getSelectedSchoolId()]); if($status->student_id){ if ($request->hasFile('file')) { $file = $request->file('file'); $file->move('images/student', $status->student_id.'.'.$file->getClientOriginalExtension()); $status->fill(['image'=>'/images/student/' . $status->student_id.'.'.$file->getClientOriginalExtension()]); $status->save(); } return $status; } }

shrutiupari started a new conversation How To Insert Into Table Only If The Status Is "approved" In Other Table?

Simple Insertion of data only if the status from other table is "Approved".

30 Aug
11 months ago

shrutiupari left a reply on Insert Multiple Rows Data Into Database

i tried it but still its shows null @Sergiu17

shrutiupari started a new conversation Insert Multiple Rows Data Into Database

I want to insert multiple rows data in the array format on select of drop down values. I tried all solutions but still data stored in db is null.

public function insert(Request $request){ $input = $request->all(); $insert= array(

        'location_name' => $request->get('location_name'),
        'location_address' => $request->get('location_address'),
        'Education_Systems' => $request->get('Education_Systems'),
        'school_id' => $this->getSelectedSchoolId(),
        'Education_Streams' => $request->get('Education_Streams'),
        'Education_Sub_Streams' => $request->get('Education_Sub_Streams'),
        'emedium' => $request->get('emedium'),
        'Grade' => $request->get('Grade')
    ); 
    $count = SchoolLocation::where('location_name',$request->get('location_name'))->exists();
    if($count){
        alert("Trying to insert already exisiting location name");
    }
    else{
        $school_loc = SchoolEduStream::insert($insert);
              
    return json_encode(array('schoolloc' => $schoolloc));      
}
  }