Answer the question
In order to leave comments, you need to log in
Laravel how to remove purchase limit?
Good day, I have such a problem. There are 4 packages. by levels. and it is arranged so that having bought the 4th level at once, you will not be able to buy the 1-2-3 level. Here is the code, how to remove this restriction?
public $sentMoney = 0;
public function createOrder(Request $request) {
$result['message'] = 'Временно недоступно';
$result['status'] = false;
if (!$request->packet_id) {
return response()->json($result);
}
if (!Auth::check()) {
return response()->json($result);
}
$price = 0;
$order_code = time();
$packet_old_price = 0;
$packet = Packet::where('packet_id', $request->packet_id)->first();
if (!$packet) {
return response()->json($result);
}
if ($packet->is_upgrade_packet) {
$is_check = UserPacket::leftJoin('packet', 'packet.packet_id', '=', 'user_packet.packet_id')
->where('user_id', Auth::user()->user_id)
->where('user_packet.is_active', '=', '0')
->count();
if ($is_check > 0) {
$result['message'] = 'Вы уже отправили запрос на другой пакет, сначала отмените тот запрос';
$result['status'] = false;
return response()->json($result);
}
$is_check = UserPacket::leftJoin('packet', 'packet.packet_id', '=', 'user_packet.packet_id')
->where('user_packet.user_id', Auth::user()->user_id)
->where('user_packet.packet_id', '>=', $request->packet_id)
->where('user_packet.is_active', 1)
->count();
if ($is_check > 0) {
$result['message'] = 'Вы не можете купить этот пакет, так как вы уже приобрели другой пакет';
$result['status'] = false;
return response()->json($result);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question