NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Write a note in this area. It's really easy to share with others. Click here .<?php

namespace AppHttpControllersAdmin;

use AppModelsCategory;
use AppModelsUser;
use AppModelsPayment;
use AppModelsChannel;
use AppHttpControllersCommonController;
use AppHttpRequestsAdminPasswordChangeRequest;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
use File;
use IlluminateSupportFacadesLog;
use Response;
use AppModelsContactSupport;
use AppMailContactSendMail;
use Mail;

class AdminAccountController extends CommonController
{
public function index(Request $request){
$roleId = ['2','3'];
$recentUser = User::whereIn('role_id',$roleId)->with('roles')->orderBy('id', 'desc')->limit(3)->get();
$endUser = User::where('role_id','3')->orderBy('id', 'desc')->count();
$broadUser = User::where('role_id','2')->orderBy('id', 'desc')->count();
return view('admin.index')->with(compact('recentUser','endUser','broadUser'));
}
public function account(Request $request){
$adminInfo = Auth::user();
return view('admin.admin-account')->with(compact('adminInfo'));
}
public function updatePassword(PasswordChangeRequest $request){
try {
$result = User::find($request->id)->update($request->authorize());
return array(
'message' => 'Record updated successfully.',
'alertType' => 'success',
);
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'status' => 'Error',
]);
}
}

public function checkLogFile(){
$file = File::get(public_path('/logs/test.log'));
$response = Response::make($file, 200);
return $response;
}

// public function donateForm($user_id, $channel_id){
// $checkExistUser = User::where('id', $user_id)->first();
// if($checkExistUser){
// $checkExistChannel = Channel::where('id', $channel_id)->first();
// if($checkExistChannel){
// return view('admin.donate.donation-form');
// } else {
// return "something went wrong !!!!";
// }
// } else {
// return "something went wrong !!!!";
// }
// }

public function donationForm($user_id, $channel_id)
{
try {
$checkExistUser = User::where('id', $user_id)->first();
Log::channel('paymentcheck')->info('Customer is found successfully ["'.$checkExistUser->id.'"] <br>', []);
$checkExistChannel = Channel::where('id', $channel_id)->first();
Log::channel('paymentcheck')->info('Customer and channel is not found !!! ["'.$checkExistUser->id. ',' .$checkExistChannel->id. '"] <br>', []);
if($checkExistUser && $checkExistChannel){
$showModel = '1';
return view('admin.donate.donation-amount-form', compact('showModel','user_id', 'channel_id'));
} else {
Log::channel('paymentcheck')->error('Channel and customer is not found <br>', []);
return redirect()->back()->with('error', 'something went wrong!!');
}
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'status' => 404,
]);
}
}

public function donatePayAmount(Request $request)
{
try{
$userId = $request->user_ids;
$channelId = $request->channel_ids;
$checkExistUser = User::where('id', $request->user_ids)->first();
Log::channel('paymentcheck')->info('Customer is found successfully ["'.$checkExistUser->id.'"] <br>', []);
$checkExistChannel = Channel::where('id', $request->channel_ids)->first();

Log::channel('paymentcheck')->info('Customer and channel is not found !!! ["'.$checkExistUser->id. ',' .$checkExistChannel->id. '"] <br>', []);
if($checkExistUser && $checkExistChannel){
Log::channel('paymentcheck')->info('Customer and channel is found !!! ["'.$checkExistUser->id. ',' .$checkExistChannel->id. '"] <br>', []);
StripeStripe::setApiKey(env('STRIPE_SECRET_KEY'));
$amount = $request->payment;
$amount *= 100;
$amount = (int) $amount;

$payment_intent = StripePaymentIntent::create([
'description' => 'Donate some money!!',
'amount' => $amount,
'currency' => 'usd',
'payment_method_types' => ['card'],
]);
$intent = $payment_intent->client_secret;
$payment_id = $payment_intent->id;
return view('admin.donate.donation-form', compact('intent','payment_id', 'userId', 'channelId'));
} else {
Log::channel('paymentcheck')->error('Channel and customer is not found <br>', []);
return redirect()->back()->with('error', 'something went wrong!!');
}
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'status' => 404,
]);
}
}

public function donateAmount(Request $request)
{
try{
$userId = $request->userId;
$channelId = $request->channelId;
$payment_intent_id = $request->payment_id;
$stripe = new StripeStripeClient(
env('STRIPE_SECRET_KEY')
);
if($stripe){
Log::channel('paymentcheck')->info('Stripe key is available!!!<br>', []);
$data = $stripe->paymentIntents->retrieve(
$payment_intent_id
);
if($data->status == "succeeded"){
Log::channel('paymentcheck')->info('Payment is success!!!<br>', []);
Payment::create(
['user_id' => $userId,
'description' => $data->description,
'transaction_id' => $data->id,
'amount' => (int) $data->amount/100,
'created_at' => $data->created,
'updated_at' => $data->updated_at,
'broadcaster_id' => $channelId,
'payout_status' => '2'
]);
Log::channel('paymentcheck')->info('Payment is created successfully!!!<br>', []);
return redirect('/thank-you');
} else {
Log::channel('paymentcheck')->error('Payment is faill!!!<br>', []);
return redirect()->back()->with('error', 'Payment is faill');
}
} else {
Log::channel('paymentcheck')->error('Stripe key not found!!!<br>', []);
return redirect()->back()->with('error', 'something went wrong!!');
}
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'status' => 404,
]);
}

}
public function thankYou()
{
return view('admin.donate.thank-you');
}

// public function payForm($user_id, $channel_id){
// $checkExistUser = User::where('id', $user_id)->first();
// if($checkExistUser){
// $checkExistChannel = Channel::where('id', $channel_id)->first();
// if($checkExistChannel){
// return view('admin.donate.pay-form');
// } else {
// return "something went wrong !!!!";
// }
// } else {
// return "something went wrong !!!!";
// }
// }

// public function payAmount()
// {
// echo 'Payment Has been Received';
// }





// public function paymentForm($user_id, $channel_id){
// $checkExistUser = User::where('id', $user_id)->first();
// $checkExistChannel = Channel::where('id', $channel_id)->first();
// if($checkExistUser && $checkExistChannel){
// return view('admin.payment.payment-form')->with(compact('user_id','channel_id'));
// } else {
// return "something went wrong !!!!";
// }
// }

// public function paymentAmount(Request $request)
// {
// try{
// $token = $request->stripeToken;
// $userId = $request->user_id;
// $channelId = $request->channel_id;
// StripeStripe::setApiKey(env('STRIPE_SECRET_KEY'));
// $checkExistUser = User::where('id', $userId)->first();
// if($checkExistUser){
// $checkExistChannel = Channel::where('id', $channelId)->first();
// if($checkExistChannel){
// $amount = 100;
// $amount *= 100;
// $amount = (int) $amount;
// $charge = StripeCharge::create(
// array(
// 'amount' => $amount,
// 'currency' => 'usd',
// 'source' => $token
// )
// );
// dd($charge);

// // $payment_intent = StripePaymentIntent::create([
// // 'description' => 'Stripe Test Payment',
// // 'amount' => $amount,
// // 'currency' => 'usd',
// // 'description' => 'Payment From Test Account',
// // 'payment_method_types' => ['card'],
// // ]);
// // $intent = $payment_intent->client_secret;
// // return view('admin.donate.donation-form', compact('intent'));
// } else {
// return "something went wrong !!!!";
// }
// } else {
// return "something went wrong !!!!";
// }
// } catch (Exception $e) {
// return response()->json([
// 'message' => $e->getMessage(),
// 'status' => 404,
// ]);
// }
// }

public function contactMailView($id)
{
try{
$data = ContactSupport::find($id);
return view('admin.contact.contact-mail')->with(compact('data','id'));
}catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'status' => 404,
]);
}
}

public function ContactSendMail(Request $request)
{
try {
$id = $request->id;
$data = ContactSupport::findOrFail($id);
if($data){
Log::info("found the data for Email ". $data->email);
$email = $data->email;
$subject = $request->Subject;
$description= strip_tags($request->description);
$details = [
'name' => $request->name,
'title' => $subject,
'body' => $description,
];
Mail::to($email)->send(new ContactSendMail($details));

Log::info("mail sent to user succesfully ". $data->email);

return response()->json([
'status' => 200,
'message' => 'Email is sent Successfully',
]);
} else{
Log::info("Recound not found for id ". $id);
return response()->json([
'status' => 404,
'message' => "Email doesn't found",
]);
}
} catch (Exception $e) {
Log::error("Error from mailer: ". $e->getMessage());
return response()->json([
'status' => "Error",
'message' =>"Something went wrong",
],500);
}
}



}

.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.