0
votes

I made a function other than resource and I am trying to update my data and the update page is showing error. I am solving this error I tried to resolve but i am unable to find way to pass second variable Error Page Image

Edit.blade.php

    @extends('home')

@section('title', '| Edit User')

@section('dashboard')

<div class='col-lg-4 col-lg-offset-4'>

    <h1><i class='fa fa-user-plus'></i> Edit {{$user->name}}</h1>
    <hr>

     <form action="{{ route('users.updated', ['id' => $user->id]) }}" method="post" enctype="multipart/form-data">
      {{ csrf_field() }}

    <div class="form-group">
        <label for="name" class="col-sm-2 col-form-label">Name *</label>

            <input type="text" class="form-control col-sm-10" id="name" name="name"
             value="{{$user->name}}" />
    </div>


    <div class="form-group">
        <label for="email" class="col-sm-2 col-form-label">Email *</label>

            <input type="email" class="form-control col-sm-10" id="email" name="email"
             value="{{$user->email}}" />
    </div>


    <h5><b>Give Role</b></h5>

    <div class='form-group'>
        @foreach ($roles as $role)
            <input class="form-check-input" type="checkbox" name="roles[]" value="{{ $role->id }}">  
  <label class="form-check-label" for="defaultCheck1">
    {{$role->name}}
  </label>
        @endforeach
    </div>

    <div class="form-group">
       <label for="password" class="col-sm-2 col-form-label">Password *</label>

            <input type="password" class="form-control col-sm-10" id="password" name="password"
            value="{{$user->password}}" />

    </div>

    <div class="form-group row"  style="margin:5%;">

            <button type="submit" class="btn btn-primary col-sm-3 col-sm-offset-3">Edit User</button>
      </div>
  </form>


</div>

@endsection

Web.php

    Route::get('users/{id}/change' ,'UserController@admin_side_edit');
        Route::post('users/savechanges/{id}', [
  'as' => 'users.updated',
  'uses' => 'UserController@admin_side_update'
]);

This is causing me the error if someone would please help me.

After changesafter update

1

1 Answers

2
votes

Actually you don't pass the id to the action, in the blade.

For you action in your form you can use this :

{{ route('users.updated', ['id' => $user->id]) }}

And don't forget to add params in the route

Route::post('users/savechanges/{id}', [
  'as' => 'users.updated',
  'uses' => 'UserController@admin_side_update'
]);

Hope this can help you.