jeudi 14 septembre 2017

Laravel: Missing 1 argument for App\Http\Controllers\ProfileController::show()

When I click "Profile" in home.blade.php I am having an error, "Missing 1 argument for App\Http\Controllers\ProfileController::show()" how to solve this error?

home.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="sidebar col-md-3">
            <div class="panel panel-default">
                <div class="panel-heading">Navigation</div>
                  @if (Auth::user()->type === "Admin")
                    <ul class="list-group">
                        <li class="list-group-item"><a href="">Users</a></li>
                        <li class="list-group-item"><a href="">Logs</a></li>
                    </ul>
                 @elseif (Auth::user()->type === "Employee")
                    <ul class="list-group">
                        <li class="list-group-item"><a href="">Profile</a></li>
                        <li class="list-group-item"><a href=""> Logs</a></li>
                    </ul>
                @else

                @endif
            </div>
        </div>  
        <div class="col-md-9">
            <div class="panel panel-default">
                <div class="panel-heading">Dashboard</div>

                <div class="panel-body">
                    You are logged in!
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Route:

Route::get('/home', 'HomeController@index');
Route::resource('/profile', 'ProfileController@show');

HomeController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        return view('home');
    }

}

ProfileController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
class ProfileController extends Controller
{

    public function index()
    {

    }


    public function create()
    {
        //
    }


    public function store(Request $request)
    {
        //
    }


    public function show($id)
    {
        $users = User::find($id);

        return view('profile.index',compact('users'));


    }


    public function edit($id)
    {
        //
    }


    public function update(Request $request, $id)
    {
        //
    }


    public function destroy($id)
    {
        //
    }
}

and this is index.blade.php of Profile folder. This is where should be the output.

@extends('layouts.app')
@section('content')
    <div class="container">
        <div class="row">

            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                        <td>User ID</td>
                        <td>First Name</td>
                        <td>Last Name</td>
                        <td>Email</td>
                        <td>Job Title</td>
                        <td>Contact No</td>
                        <td>ABN Number</td>
                        <td>Status</td>
                        <td>Type</td>
                        <td>Action</td>
                    </thead>
                    <tbody>                                     
                        @foreach($users as $value)  
                            <tr>
                                <td></td>                           
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td>
                                    <a href="">
                                        Edit
                                    </a>                                                    
                                    <a href="">
                                        Delete
                                    </a>
                                </td>   
                            </tr>                   
                         @endforeach                                         
                    </tbody>
                </table>
            </div>



        </div>
    </div>
 @endsection

How to solve this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire