Sunday, May 21, 2017

If record exist disabled button in laravel 5.4

I am trying to disable a button if I have a user registered in my user table, but with the method that I am using does not inactivate the button that I want to be inactive, it is inactivating it to all the registers.

This is my index method controller:

public function index(Request $request)
    {
        $employees = Employee::name($request->get('criteria'))->orderBy('name','asc')->paginate(6);

        $departments = Department::orderBy('id', 'desc')->pluck('name', 'id');

        $users = User::orderBy('id', 'desc')->pluck('username', 'id');

        return view('employees.index', compact('employees', 'departments', 'users'))
        ->with('i', ($request->input('page', 1) - 1) * 6);
    }

And this is my blade view with button:

<td>
    <div class="btn-group">                                     
        @if(count($users) === 0)
        <a href="" type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" rel="tooltip" data-placement="top" title="Confirmar votante">Confirmar</a>

        @else
            <a type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" rel="tooltip" data-placement="top" disabled="disabled" title="Confirmar votante">Confirmar</a>

        @endif
    </div>
</td>



via Edward Palen

Advertisement