如何解决Laravel 6.0错误上传文件

时间:2019-11-16 23:13:34

标签: laravel

我正在尝试向数据库输入一些数据 我无法将某些数据输入数据库,因为出现了该错误 但我可以在项目中使用多身份验证登录

我遇到了一些错误 enter image description here

我该如何解决此错误?

控制器

    <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Jurusan;
use Auth;
class AdminActionsController extends Controller
{
    public function addjurusan(Request $request)
    {

        $jurusan = new Jurusan();
        $jurusan->nama_jurusan=$request->nama;
        $file=$request->file('fotohimpunan');
        if (!$file) {
            return redirect()->route('in.jurusan')->with('alert','foto harus diisi!');
        }
        $file_name=$file->getClientOriginalName();
        $path=public_path('/img');
        $file->move($path,$file_name);
        $jurusan->fotohimpunan='public/img/'.$file_name;
        $jurusan->status='disable';
        // dd($jurusan);
        $jurusan->save();


        return redirect()->route('in.jurusan');
    }
}

后卫

<?php
return [
    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],
    // Guard
    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
        'admin' => [
          'driver' => 'session',
          'provider' => 'admin',
        ],
        'admin-api' => [
            'driver' => 'token',
            'provider' => 'admin',
        ],
        'panitia' => [
          'driver' => 'session',
          'provider' => 'panitia',
        ],
        'panitia-api' => [
            'driver' => 'token',
            'provider' => 'panitia',
        ],
        'mahasiswa' => [
          'driver' => 'session',
          'provider' => 'mahasiswa',
        ],
        'mahasiswa-api' => [
            'driver' => 'token',
            'provider' => 'mahasiswa',
        ],

    ],
    //  Providers
    'providers' => [
        'panitia' => [
            'driver' => 'eloquent',
            'model' => App\Panitia::class,
        ],
        'admin' => [
          'driver' => 'eloquent',
          'model' => App\Admin::class,
        ],
        'mahasiswa' => [
          'driver' => 'eloquent',
          'model' => App\Mahasiswa::class,
        ],

    ],
    // Password
    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
    ],
];

我如何解决我的问题,请帮助我 我可以使用多身份验证登录,但是如果我尝试输入一些数据,则会收到该错误

1 个答案:

答案 0 :(得分:1)

您没有users提供者:

'providers' => [
    'panitia' => [
        'driver' => 'eloquent',
        'model' => App\Panitia::class,
    ],
    'admin' => [
      'driver' => 'eloquent',
      'model' => App\Admin::class,
    ],
    'mahasiswa' => [
      'driver' => 'eloquent',
      'model' => App\Mahasiswa::class,
    ],

],

web防护设置为使用名为users的提供程序:

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

您需要调整它以使用已注册的provider,或添加一个users提供程序。

您是否打算使用web防护程序来寻找哪个路线并遇到错误?您可能打算完全使用其他防护罩。