When user sign up he get free amount of 100, amount is present in the "USERS" table. I want that a user cannot withdraw (amount in "Withdraw" table), if he has no record in the "Fund" table.
I tried the following in the withdraw controller. If the "Fund" table holds a record, it will return the view, otherwise it will redirect to login.
Is this right?
public function newWithdraw()
{
$fund = Fund::where('user_id', Auth::user()->id)->first();
if ($fund==null)
{
Session::flash('type','danger');
Session::flash('message','please add funds atleast once');
return redirect()->route('login');
}
else
$data['general'] = GeneralSetting::first();
$data['site_title'] = $data['general']->title;
$data['basic'] = BasicSetting::first();
$data['page_title'] = "User Withdraw Method";
$data['method'] = ManualPayment::whereStatus(1)->get();
return view('withdraw.withdraw-new',$data);
}
Use empty()
to check Fund
have a record or not.
public function noamount()
{
$fund = Fund::where('user_id', Auth::user()->id)->first();
if (empty($fund)) {
return redirect()->back()->with('type','danger')->with('message','please add funds atleast once');
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.