1

I am getting the following error:

FatalErrorException in usercontroller.php line 21: Class 'APP\User' not found

usercontroller.php:

<?php

namespace App\Http\Controllers;
use APP\User;
use Illuminate\Http\Request;
use App\Http\Requests;


class usercontroller extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $user = User::all();
        return view('admin/users', compct('user'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

User.php (it's in App/User.php):

<?php

namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

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

I create to users.blade.php to listing user in Admin Panel but at last then i m click to a user then they have an error on screen please say what can i do

3
  • 1
    Instead of use APP\User; you can use use App\User; Commented Jan 23, 2019 at 10:31
  • @InzamamIdrees i m use this "use App\User;" but they give another error like this FatalErrorException in usercontroller.php line 21: Call to undefined function App\Http\Controllers\compct() Commented Jan 23, 2019 at 10:41
  • 3
    Beceause it's compact() not compct Commented Jan 23, 2019 at 10:43

3 Answers 3

2

Typo

Change use APP\User; to use App\User;

It's case sensitive so they are not the same thing.

Sign up to request clarification or add additional context in comments.

1 Comment

i m use this "use App\User;" but they give another error like this FatalErrorException in usercontroller.php line 21: Call to undefined function App\Http\Controllers\compct()
1

please use User class in UserController with this namespace App/User NOT APP/user

2 Comments

i m use this "use App\User;" but they give another error like this FatalErrorException in usercontroller.php line 21: Call to undefined function App\Http\Controllers\compct()
Beceause it's compact() not compct
1

Change use APP\User; to use App\User;

Change also compct to compact

public function index()
{
    $user = User::all();
    return view('admin/users', compact('user'));
}

1 Comment

i m use this "use App\User;" but they give another error like this FatalErrorException in usercontroller.php line 21: Call to undefined function App\Http\Controllers\compct()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.