0

I have this view page index.blade.php

@section('main')

<h1>All Users</h1>

<p><a href={!! url('users\create') !!}>Add new user</a></p>

@if ($users->count())
    <table border="2">
<tr><td>s.n.</td><td>name</td><td>email</td><td>options</td>
            @foreach ($users as $user)
           <tr>
<td>{{ $user->id }}</td>
        <td>{{ $user->name }}</td>
    <td>{{ $user->email }}</td>
                    <td><a href={{ url('users\{id}\edit', $user->id)}}>Edit</a>

<td>
          {!! Form::open(array('method' => 'DELETE', 
        'route' => array('users.destroy', $user->id))) !!}                       
                            {!! Form::submit('Delete', array('class' => 'btn btn-danger')) !!}
                        {!! Form::close() !!}
                    </td>                
</tr>
      @endforeach


    </table>
@else
    There are no users
@endif

@stop

and controller

<?php



namespace App\Http\Controllers;


use Illuminate\Http\Request;


use App\Http\Requests;

use App\Http\Controllers\Controller;


use App\User;

class usercontroller extends Controller

{

  public function index()
  {

    $users=User::all();
    return view('users.index', compact('users'));
  }

  public function create()
  {
    return View('users.create');
  }

  public function store()
  {

        $input = Input::all();
        $validation = Validator::make($input, User::$rules);

        if ($validation->passes())
        {
            User::create($input);

            return Redirect::route('users.index');
        }

        return Redirect::route('users.create')
            ->withInput()
            ->withErrors($validation)
            ->with('message', 'There were validation errors.');
  }

  public function show($id)
  {
    //
  }
  public function edit($id)
  {
  $user = User::find($id);
        if (is_null($user))
        {
            return Redirect::route('users.index');
        }
        return View('users.edit', compact('user'));
  }

  public function update($id)
  {
    $input = Input::all();
        $validation = Validator::make($input, User::$rules);
        if ($validation->passes())
        {
            $user = User::find($id);
            $user->update($input);
            return Redirect::route('users.show', $id);
        }
return Redirect::route('users.edit', $id)
            ->withInput()
            ->withErrors($validation)
            ->with('message', 'There were validation errors.');
  }
  public function destroy($id)
  {
    User::find($id)->delete();
        return Redirect::route('users.index');
  }

}

and

 routes.php
Route::resource('users', 'UserController');

but when i enter laravel/public/users it displays the white blank page. same problem with any other routes such as:

Route::get('/users/edit/{id}','UserController@edit');
Route::put('/users/{id}','UserController@update');
Route::delete('/users/{id}','UserController@delete');

the problem occurred when i follow these steps https://laravelcollective.com/docs/5.2/html to use forms. . earlier the error was 'class form' not found.

the app/User.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;

class User extends BaseModel
{
    protected $primarykey='id';
    protected $table='users';
        protected $fillable=array('name','email','password');

 public static $rules = array(
    'name' => 'required|min:5',
    'email' => 'required|email'
  );
}

and basemodel

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;

class BaseModel extends Model {

    public function selectQuery($sql_stmt) {
        return DB::select($sql_stmt);
    }

    public function sqlStatement($sql_stmt) {
        DB::statement($sql_stmt);
    }
}
micky
  • 277
  • 1
  • 13
  • 39
  • Anything in storage/logs/laravel.log? Anything in your webserver's log? Have you checked permissions are as they should be? – tremby Mar 15 '16 at 04:59
  • @tremby the latest line is:`#37 C:\xampp\htdocs\laravel\public\index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))` – micky Mar 15 '16 at 13:26

1 Answers1

0

at first change your controller file name app/Http/Controller/usercontroller.php to app/Http/Controller/UserController.php.
then in UserController.php you edit your class name like below:

<?php



 namespace App\Http\Controllers;


 use Illuminate\Http\Request;


 use App\Http\Requests;

 use App\Http\Controllers\Controller;


 use App\User;

 class UserController extends Controller


Then make sure that you have a model name app/User.php which contains all the table field and table name.
In app/Http/routes.php you set another route

Route::get('users','UserController@index');

then you can enter laravel/public/users

Nadimul De Cj
  • 484
  • 4
  • 16