Manthero Camth
Manthero Camth

Reputation: 1

Undefined array key "email"

I can't seems to find the reason why it gives me the error Undefined array key "email" I'm sorry in advance if the info that I'm providing is not enough please tell me what info you guys need.

here is my admin controller


namespace App\Http\Controllers\Admin;

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

class AdminController extends Controller
{
    public function dashboard()
    {
        return view('admin.dashboard');
    }

    public function login(Request $request)
    {
        if ($request->isMethod('post')) {
            $data = $request->all();
            // echo "<pre>";
            // print_r($data);
            // die;

            if (Auth::guard('admin')->attempt(['email' => $data['email'], 'password' => $data['password'], 'status' => 1])) {
                return redirect('admin/dashboard');
            } else {
                return redirect()->back()->with('error_message', 'Invalid Email or Password');
            }
        }
        return view('admin.login');
    }
}

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Admin extends Authenticatable
{
    use HasFactory;
    protected $guard = 'admin';
}

I already try changing the ['email' => $data['email'] to $data['email'] = '[email protected]'

but it just give me the error that i have to migrate again which i'm not aiming for, should i migrate?

Upvotes: 0

Views: 643

Answers (0)

Related Questions