Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
192 views
in Technique[技术] by (71.8m points)

how to solve Laravel 6.0 error upload file

I'm trying to input some data to database i cant input some data to database because i got that error but i can login with multi auth in my project

and i got some error enter image description here

how i can solve this error?

controller

    <?php

namespace AppHttpControllers;

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

guard

<?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' => AppPanitia::class,
        ],
        'admin' => [
          'driver' => 'eloquent',
          'model' => AppAdmin::class,
        ],
        'mahasiswa' => [
          'driver' => 'eloquent',
          'model' => AppMahasiswa::class,
        ],

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

how i can solve my problems please help me i can login with multi auth but if i try to input some data i got that error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You don't have a users provider:

'providers' => [
    'panitia' => [
        'driver' => 'eloquent',
        'model' => AppPanitia::class,
    ],
    'admin' => [
      'driver' => 'eloquent',
      'model' => AppAdmin::class,
    ],
    'mahasiswa' => [
      'driver' => 'eloquent',
      'model' => AppMahasiswa::class,
    ],

],

The web guard is set to use a provider named users:

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

You need to adjust that to use a provider you have registered, or add a users provider.

Are you intending to be using the web guard for which ever route you are hitting and getting the error? It is possible you intend to use a different guard completely.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...