1
我只是想更新我的數據庫表Time_tracker,但當我嘗試某些東西時,我總是收到錯誤。誰能幫我這個?當前的錯誤是PaypalController.php中的ErrorException第57行: 試圖獲取非對象的屬性Laravel 5.2更新數據庫表
這是代碼。
PaypalController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Mail\Mailer;
use App\Maintenance;
use App\Time_tracker;
class PaypalController extends Controller {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index() {
return view('paypal');
}
public function success() {
$price = \Session::get('value_price');
$value = $price;
if($value == '465'){
$user_id = Auth::user()->id;
$Totalpurchase = DB::table('time_tracker')->where('user_id', $user_id->user_id)->sum('purshase_time');
$purchase = $Totalpurchase + 15;
DB::table('users')
->where('user_id', $user_id)
->update(['status' => 'paid',
'purshase_time' => $purchase_time
]);
}elseif($value == '700'){
$user_id = Auth::user()->id;
$Totalpurchase = DB::table('time_tracker')->where('user_id', $user_id->user_id)->sum('purshase_time');
$purchase = $Totalpurchase + 25;
DB::table('users')
->where('user_id', $user_id)
->update(['status' => 'paid',
'purshase_time' => $purchase_time
]);
}elseif($value == '1300'){
$user_id = Auth::user()->id;
$Totalpurchase = DB::table('time_tracker')->where('user_id', $user_id->user_id)->sum('purshase_time');
$purchase = $Totalpurchase + 50;
DB::table('users')
->where('user_id', $user_id)
->update(['status' => 'paid',
'purshase_time' => $purchase_time
]);
}
return view('success');
}
public function failed() {
return view('failed');
}
}
是的,它的工作原理!非常感謝! – Ace