mercredi 19 octobre 2016

Laravel not applying fill properly?

For some reason fill isn't... well filling. No errors, just nothing updating. I know the fill command is correctly working, because returning the $user afterwards gives me the respective fields modified. But somewhere the information isn't getting put into the database.

The blade can be found here: http://ift.tt/2e8kJQX The request form can be found here: http://ift.tt/2evSFoB

This is the controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests\UserFormRequest;
use App\UserEdit;
use DB;
use App\Http\Requests;

class EditUserController extends Controller
{
    public function index()
    {
        $array = UserEdit::all()->toArray();
        return view('UserEntry', compact('array'));
    }

    public function create()
    {
        //
    }

    public function store()
    {
      //
    }

    public function show($ID)
    {
        try {
         $array = UserEdit::findorFail($ID)->toArray();
         return view('UserEdit')->with('array', $array);

         } catch(\Exception $e) {
             return \Redirect::route('users.index')
                ->withMessage('This user does not exist');
         }

    }

    public function edit(UserEdit $user)
    {

        return view('EditUser', compact('user'));
    }

    public function update(UserEdit $user, UserFormRequest $request)
    {
       //$user->fill($request->all());

       $user->fill([
           'name' => $request->get('name'),
           'email' => $request->get('email')
      ]);

       return \Redirect::route('users.edit', [$user->ID])->with('message', 'Details Updated!');
    }

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

Pretty sure that's all above board, so why wouldn't it work? Am I missing some detail somewhere? This is the model: http://ift.tt/2e8m6iw



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire