For some reason I can't save to the database. No errors, just nothing updating. I know the commands are 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://pastebin.com/8bAEsjtj The request form can be found here: http://pastebin.com/ZCD1Xvjn
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(UserFormRequest $request, UserEdit $user)
{
//$input->$request->all();
//$user->fill(Input::all());
$user->fill([
'name' => $request->get('name'),
'email' => $request->get('email'),
'First_Name' => $request->get('First_Name'),
'Last_Name' => $request->get('Last_Name')
]);
//$user->name = Input::get('name');
//$user->email = Input::get('email');
//$user->First_Name = Input::get('First_Name');
//$user->Last_Name = Input::get('Last_Name');
$user->save();
//$user->save();
// return redirect()->route('users.index')->with('message', 'Details Updated!');
return $user;
}
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://pastebin.com/vJBzfUVu
Ok. Found the answer, there's a difference between how mysql and php handle the 'id' in a database table.
In this instance, because I've inherited the database from other devs, the id column was capitalised.
This probably made the php laravel generates throw an error as it was looking for 'id' and didn't find anything.
I didn't notice this because it didn't actually print that error, and my other code was accounting for the capitalisation.
Changing the ID to id and fixing the references in my code seems to have solved the problem.