Dennys

Dennys

Member Since 2 Months Ago

Experience Points
180
Total
Experience

4,820 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.

Level 1
180 XP
Sep
17
3 weeks ago
Activity icon

Started a new conversation "These Credentials Do Not Match Our Records" In Laravel 5.8 Auth Login Page

Hello,

after restoring my laravel project backup I can't login anymore, the authentication used to work well, I can't understand which is the problem.

I configured the .env file to work with the database and the migration works, so the database connection shouldn't be the problem.

It's a multi-table authentication with two different login page.

This is my web.php with the routes:

<?php
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Auth::routes([
    'register' => false,
    'verify' => false,
    'reset' => false
]);

Route::group(['prefix' => 'formatore',  'middleware' => 'auth:formatore'],function (){
    Route::get('/login', 'Auth\[email protected]')->name('formatore.login');
    Route::post('/login', 'Auth\[email protected]')->name('formatore.login.submit');
    Route::get('/', '[email protected]')->name('formatore.dashboard');
});

Route::group(['prefix' => 'home',  'middleware' => 'auth:web'],function (){
    Route::get('/', '[email protected]')->name('utente.dashboard');
});

The auth.php in the config folder:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Authentication Defaults
    |--------------------------------------------------------------------------
    */

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    /*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    */

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],

        'formatore' => [
            'driver' => 'session',
            'provider' => 'formatori',
        ],

        'formatore-api' => [
            'driver' => 'token',
            'provider' => 'formatori',
            'hash' => false,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | User Providers
    |--------------------------------------------------------------------------
    */

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],

        'formatori' => [
            'driver' => 'eloquent',
            'model' => App\Formatore::class,
        ],
    ],
];

The LoginController:

<?php

namespace App\Http\Controllers\Auth;

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

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    */

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

The FormatoreLoginController:

<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

class FormatoreLoginController extends Controller
{

    public function __construct()
    {
        $this->middleware('guest:formatore');
    }

    public function showLoginForm()
    {
        return view('auth.formatore-login');
    }

    public function login(Request $request)
    {
        $remember = $request->remember;

        $this->validate($request, [
            'email' => 'required|email',
            'password' => 'required|min:6'
        ]);

        if (Auth::guard('formatore')->attempt(['email' => $request->email, 'password' => $request->password], $remember)) {
            return redirect()->intended(route('formatore.dashboard'));
        }

        return redirect()->back()->withInput($request->only('email', 'remember'));
    }
}

These are the pages that I find useful, I deleted the part of code that i find useless.

Thank you very much for the help, it's appreciated.

Sep
09
1 month ago
Activity icon

Replied to Live Search In Laravel 5.8 Using AJAX Doesn't Show Results In The Table

Thanks for the answers, I finally solved the problem moving the script inside the html part avoiding to use "@push('head')", and adding "script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"" at the begging of the view.

Activity icon

Replied to Live Search In Laravel 5.8 Using AJAX Doesn't Show Results In The Table

Thanks for your help, appreciated. But unfortunately the problem persists despite the corrections.

Sep
05
1 month ago
Activity icon

Started a new conversation Live Search In Laravel 5.8 Using AJAX Doesn't Show Results In The Table

Hello,

following a guide found on the web I developed a table which show data from a database and a live search bar which filter the results on the table, the problem is that it doesn't show any result (even without typing in the search bar).

I've been trying to solve the problem for hours without success. Can someone help me please?

Many thanks in advance.

This is my view:

@extends('layouts.app')

@section('content')

    @push('head')
        <script>
            $(document).ready(function () {

                fetch_customer_data();

                function fetch_customer_data(query = '') {
                    $.ajax({
                        url: "{{route('formatore.utenti.action')}}",
                        method: 'GET',
                        data: {query: query},
                        dataType: 'json',
                        success: function (data) {
                            $('tbody').html(data.table_data);
                        }
                    })
                }

                $(document).on('keyup', '#search', function () {
                    var query = $(this).val();
                    fetch_customer_data(query);
                });
            });
        </script>
    @endpush


    <div class="container" xmlns="http://www.w3.org/1999/html">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">Lista utenti</div>
                    <div class="card-body">
                        <div class="form-group">
                            <input type="text" name="search" id="search" class="form-control"
                                   placeholder="Cerca utenti" />
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped table-hover table-sm">
                                <thead>
                                <tr>
                                    <th>Nome</th>
                                    <th>Cognome</th>
                                    <th>Settore</th>
                                    <th>Località</th>
                                    <th>Data di nascita</th>
                                    <th>Telefono</th>
                                    <th>Cellulare</th>
                                    <th>Email</th>
                                </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div>
                        <a href="{{ route('formatore.dashboard') }}">
                            <button type="button" class="btn btn-secondary btn-lg btn-block">Torna alla home</button>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

This is the controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class UtentiController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth:formatore');
    }

    public function index()
    {
        return view('utenti');
    }

    function action(Request $request)
    {
        if ($request->ajax()) {
            $output = '';
            $query = $request->get('query');
            if ($query != '') {
                $data = DB::table('users')
                    ->select('nome','cognome','settore','indirizzo_localita','data_nascita','telefono','cellulare','email')
                    ->where('nome', 'like', '%' . $query . '%')
                    ->orWhere('cognome', 'like', '%' . $query . '%')
                    ->orWhere('settore', 'like', '%' . $query . '%')
                    ->orWhere('indirizzo_localita', 'like', '%' . $query . '%')
                    ->get();
            } else {
                $data = DB::table('users')
                    ->select('nome','cognome','settore','indirizzo_localita','data_nascita','telefono','cellulare','email')
                    ->orderBy('created_at', 'desc') //creared at non ce nella select
                    ->get();
            }
            $total_row = $data->count();
            if ($total_row > 0) {
                foreach ($data as $row) {
                    $output .= '
                    <tr>
                    <td>'. $row->nome.'</td>
                    <td>'. $row->cognome.'</td>
                    <td>'. $row->settore.'</td>
                    <td>'. $row->indirizzo_localita.'</td>
                    <td>'. $row->data_nascita.'</td>
                    <td>'. $row->telefono.'</td>
                    <td>'. $row->cellulare.'</td>
                    <td>'. $row->email.'</td>
                    </tr>
                    ';
                }
            } else {
                $output .= '
                <tr>
                <td align="center" colspan="5">
                Nessun dato trovato
                </td>
                </tr>
                ';
            }
            $data = array(
                'table_data' => $output
            );
            echo json_encode($data);
        }
    }
}

These are the routes: (the last 2 are about the live search page)

<?php

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Auth::routes([
    'register' => false,
    'verify' => false,
    'reset' => false
]);

Route::get('/home', '[email protected]');

Route::prefix('formatore')->group(function (){
    Route::get('/login', 'Auth\[email protected]')->name('formatore.login');
    Route::post('/login', 'Auth\[email protected]')->name('formatore.login.submit');
    Route::get('/', '[email protected]')->name('formatore.dashboard');
    Route::get('/h', '[email protected]')->name('formatore.h');
    Route::get('/q', '[email protected]')->name('formatore.q');
    Route::get('/utenti', '[email protected]')->name('formatore.utenti');
    Route::get('/utenti/action', '[email protected]')->name('formatore.utenti.action');
});

The columns of the "users" table are "id_utente", "id_formatore", "nome", "cognome", "sesso", "indirizzo_titolo", "indirizzo_via", "indirizzo_cap", "indirizzo_localita", "settore", "data_nascita", "stato_civile", "num_avs", "nazionalita", "permesso", "iban", "telefono", "cellulare", "email", "email_verified_at", "password", "attivo", "remember_token", "id_colloquio", "created_at" and "updated_at"

Sep
03
1 month ago
Activity icon

Replied to Laravel ID Authentication With Users From Multiple Tables

Thank you very much for your reply, I solved separating the login in two different pages and I kept "Formatore" and "User" in two different tables because they have two completely different functions.

Thanks

Aug
27
1 month ago
Activity icon

Started a new conversation Laravel ID Authentication With Users From Multiple Tables

Hello, can someone help me please?

I want to authenticate users with ID and Password, not email. I have to authenticate users from "Utente" table, but I also want to authenticate other users from "Formatore" table. I tried in many way but nothing worked.

I don't need the users to register, I only need the login page.

The LoginController is already generated and the view is already edited with the two imput (id and password).

How can I solve?

Many thanks in advance.