Categories
forms laravel-5 mysql php sql-update

Laravel 5.1 update query not changing value

good evening,

I have run into a problem with a query update it returns no error but also doesn’t update the value in the defined field users defined field. I’ve tried removing the foreach and adding specific elements into the query like shown below but that didn’t effect the field results as well.

$UserUpdate = DB::table('users')->where('id', '=', 3)->update(array('StockAcc' => 6));

Controller

 namespace App\Http\Controllers;
use \View as View;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\HTTP\Request;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class TransController extends BaseController
{
public function Trans(Request $Return)
{
$id = $Return->input('id');
$uid = $Return->input('uid');
$Math = $Return->input('Math');
$Pin = $Return->input('Pin');
$Buy = $Return->input('Buy');
$Sell = $Return->input('Sell');
/*
* Querys for DB results
*/
$User = DB::Table('users')->where('id', $uid);
foreach ($User as $item) {
$Final = $Buy * $Math;
$NewMoney = $Final - $item->StockAcc;
$UserUpdate = DB::table('users')
->where('id', '=', $uid)
->update(array('StockAcc' => $NewMoney));
}
}
}

Route

 Route::get('/Display', array(
'middleware' => 'auth',
'uses' => '[email protected]'
));
Route::post('/test', function(){
});

View:

{!!Form::open(array('action' => '[email protected]', 'url' => ' '))!!}