Bu Apide ki geri dönüşleri özelleştirmek Laravel 5.5 kullanıyor ve kaynak bulamıyorsanız Ölüm 😃
@mgsmus Abi burada ki validation mesajlarından birisi bile sağlanmasa hepsini basıyor ekrana bunları doğru düzgün yapamaz mıyım bir yol gösterir misin 😃
try {
$user=User::whereEmail($request->email)->first();
$registerData = $this->validate($request, [
'first_name' => 'required',
'last_name' => 'required',
'phone_number' => 'required|min:10',
'email' => 'required',
'company_name' => 'required',
'company_type' => 'required',
'tax_number' => 'required',
'tax_office' => 'required',
'invoice_city' => 'required',
'invoice_district' => 'required',
'grand_total' => 'required',
'parampos_id' => 'required',
'product.*.product_id' => 'required',
'product.*.product_price_id' => 'required',
'product.*.qty' => 'required',
'product.*.sub_total' => 'required',
'product.*.tax' => 'required',
'product.*.tax_total' => 'required',
'product.*.currency' => 'required',
'product.*.grand_total' => 'required',
// 'info_form' => 'required|accepted',
],
[
'first_name.required' => 'Adınızı girmeniz gerekmektedir.',
'last_name.required' => 'Soyadınızı girmeniz gerekmektedir.',
'phone_number.required' => 'Telefon numaranızı girmeniz gerekmektedir.',
'phone_number.min' => 'Telefon numaranızı doğru girmeniz gerekmektedir.',
'phone_number.unique' => 'Telefon numarası kullanılmaktadır.',
'email.min' => 'E-Mail adresinizi girmeniz gerekmektedir.',
]);
if(is_null($user))
{
$registerData['password'] = \Hash::make('c{SbG9Tw%ne~\?Ss');
if ($registerData['company_type'] == 'individual') {
$companyType = 0;
} else {
$companyType = 1;
}
$registerData['confirmation_code'] = md5(uniqid(mt_rand(), true));
$registerData['expired_at'] = Carbon::now()->addDays(21);
$registerData['confirmed'] = 1;
$registerData['partner_token_id'] = 3;
$user = User::create($registerData);
$user->assignRole('business');
$addresses = $user->addresses()->create([
'first_name' => $registerData['first_name'],
'last_name' => $registerData['last_name'],
'phone_number' => $registerData['phone_number'],
'user_id' => $user->id,
'company_name' => $registerData['company_name'],
'company_type' => $companyType,
'is_company' => $companyType,
'tax_number' => $registerData['tax_number'],
'tax_office' => $registerData['tax_office'],
'invoice_city' => $registerData['invoice_city'],
'invoice_district' => $registerData['invoice_district'],
]);
}
$addressId = $addresses->id ?? $user->addresses()->first()->id;
$payment = $user->payments()->create([
'price' => $registerData['grand_total'],
'address_id' => $addressId,
'name_lastname' => $user->full_name,
'zipcode' => '34000',
'payment_status' => 1,
'day' => 0,
'type' => 'year',
'mdStatus' => 1,
'source' => 'Roket',
'payment_type'=>'credit_card'
]);
$payment->logs()->create([
'data' => $registerData['parampos_id'],
'user_id' => $user->id,
]);
if (is_array($request->input('product'))) {
foreach ($registerData['product'] as $product) {
$product_data = Product::find($product['product_id']);
$item_data = ProductPrice::find($product['product_price_id']);
$payment->data()->create([
'product_price_id' => $product['product_price_id'],
'product_id' => $product['product_id'],
'sub_total' => $product['sub_total'],
'product_data' => $product_data,
'item_data' => $item_data,
'tax' => $product['tax'],
'qty' => $product['qty'],
'tax_total' => $product['tax_total'],
'grand_total' => $product['grand_total'],
'payment_status' => PaymentStatus::SUCCESS,
'currency' => $product['currency'],
'user_id' => $user->id,
]);
}
}
return response()->json([
'message' => 'Payment has beed added succesfully',
'data' => [
'user_id' => $user->id,
],
'status' => 'success',
], 200);
}
catch (\Exception $exception)
{
return response()->json([
'message' => $exception,
'data' => [
],
'status' => 'error',
], 422);
}