TaskQueue.php Error - Laravel 5 & Forge - laravel

When running any Posts and Model::create function within Laravel I am being greeted with the below error;
FatalErrorException in TaskQueue.php line 13:
Interface 'GuzzleHttp\Promise\TaskQueueInterface' not found
This was working perfectly fine on my local machine but as soon as the website was put onto a server with Forge it has started to show this error.
It looks like the server is trying to use the Queue function with Laravel but my code doesn't ever make use of this;
public function postCreateCustomer(){
$input = Request::all();
$customer = Customers::create([
'customer_name' => $input['customer_name'],
'customer_url' => $input['customer_url']
]);
$password = str_random(8);
$pass = Hash::make($password);
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => $pass,
'user_type' => 3,
'active_customer' => $customer->id,
]);
Access::create([
'user_id' => $user->id,
'customer_id' => $customer->id
]);
$the_content = '<p>Hello '.$input['name'].' ('.$input['customer_name'].'),</p>
<p>Thank you for creating an account. </p>
<p>Your login details are listed below;</p>
<p><strong>Username</strong>: '.$input['email'].'<p>
<p><strong>Password</strong>: '.$password.'<p>';
$contactEmail = $input['email'];
Mail::send('emails.default', ['the_content' => $the_content, 'the_heading' => 'Customer Account Created'], function ($message) use ($contactEmail) {
$message->subject("Customer Account Created");
$message->to($contactEmail);
});
Session::flash('success_message', 'The new customer has been created.');
return Redirect::to('/customers');
}

I faced the same problem and I found that was caused by the class "TaskQueueInterface" had not be found.
The following is my solution:
open the folder: /vendor/guzzlehttp/promises/src
edit TaskQueue.php
modify "class TaskQueue implements TaskQueueInterface" to "class TaskQueue"
After doing the above, stay tuned for the official release.

Related

Pusher trigger() method is giving error 500

So I was building chat functionality in laravel for a website using Pusher , everything was working fine till yesterday. But when I run the chat module again, I found out that trigger() method is giving error (Internal server error).
`
use App\Http\Controllers\Controller;
use App\Model\Chatting;
use App\Model\Seller;
use App\Model\Shop;
use Brian2694\Toastr\Facades\Toastr;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Events\Message;
use Pusher\Pusher;
class ChattingController extends Controller
{
public function seller_message_store(Request $request)
{
//return 'hello';
if ($request->message == '') {
Toastr::warning('Type Something!');
return response()->json('type something!');
} else {
$shop_id = Shop::where('seller_id', auth('seller')->id())->first()->id;
$message = $request->message;
$time = now();
DB::table('chattings')->insert([
'user_id' => $request->user_id, //user_id == seller_id
'seller_id' => auth('seller')->id(),
'shop_id' => $shop_id,
'message' => $request->message,
'sent_by_seller' => 1,
'seen_by_seller' => 0,
'created_at' => now(),
]);
//return auth('seller')->user()->seller_plan_id;
if(auth('seller')->user()->seller_plan_id>2){
// pusher
$options = array(
'cluster' => 'ap2',
'useTLS' => false
);
$pusher = new Pusher('app auth key','app secret','app_id',$options);
//return $request->user_id;
$data = ['from' => auth('seller')->id(), 'to' => $request->user_id,'message'=>$request->message]; // sending from and to user id when pressed enter
$pusher->trigger('channel-name', 'event', $data);//here is the issue
}
return response()->json(['message' => $message, 'time' => $time]);
}
}
}
`
If I comment out the trigger line, it gives no error.
It was working completely fine till yesterday.
The version 5.0 of pusher is broken and has given me errors in the past.
What you could do is, change
"pusher/pusher-php-server": "5.0"
to
"pusher/pusher-php-server": "^5.0"
And then run the command composer update

Not getting data for authenticated user from database in Laravel for setting stripe

I've been trying to get the saved customer id for stripe from database but with no luck.
It works everywhere else, I could get it and save it again if I wanted, but whenever I try to use it in payment intent to automatically renew a subscription, it gives me this error: Trying to get property 'stripecustomerid' of non-object.
this is the bit of the stripe code for recurring charge where the error happens:
public function renew($subscription)
{
\Stripe\Stripe::setApiKey('sk_test_XXXXXXXX');
header('Content-Type: application/json');
try {
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$user = \Auth::user();
$payment_methods = \Stripe\PaymentMethod::all([
'customer' => $user->stripecustomerid,
'type' => 'card'
]);
$payment_intent = \Stripe\PaymentIntent::create([
'amount' => $subscription->plan->stripePrice(),
'currency' => 'usd',
'customer' => $user->stripecustomerid,
'payment_method' => $payment_methods->data[0]->id,
'off_session' => true,
'confirm' => true,
]);
echo json_encode([
'paymentIntent' => $payment_intent,
]);
}
catch (\Exception $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
}
and stripecustomerid is the name of the column where I saved the customer id.
I can print it in another function, and it works when I use GET, but it just doesn't work when the subscription tries to renew.

Trying to get property 'id' of non-object error from aws eb after deployment

I am having this error after deploying to aws elastic beanstalk
the code is normally functional on my localhost.
can anyone please help me?
This is from my controller:
public function store(Request $request)
{
$location = DB::table('branches')->where('codename', $request->location)->first();
$uId = $request->user_id;
// User::updateOrCreate(['id' => $uId], ['name' => $request->name, 'email' => $request->email, 'active' => $request->active]);
User::where('id', '=', $uId)->update(['name' => $request->name, 'email' => $request->email, 'active' => $request->active, 'loc_code' => $request->location, 'usercode' => $location->id, 'loc_name' => $location->name]);
$msg = 'User data is updated successfully';
return redirect()->route('admin.user-list')->with('success', $msg);
}
this is from my blade:
$('body').on('click', '#edit-repair', function() {
var repair_id = $(this).data('id');
$.get('/repair/' + repair_id + '/edit', function(data) {
$('#userCrudModal').html("Edit Repair");
$('#btn-update').val("Update");
$('#btn-save').prop('disabled', false);
$('#crud-modal').modal({
backdrop: 'static',
keyboard: false
});
$('#crud-modal').modal('show');
$('#joborder').val(data.joborder);
$('#createdby').val(data.createdBy);
$('#location').val(data.activeLoc);
$('#fname').val(data.fname);
$('#lname').val(data.lname);
$('#address').val(data.address);
$('#contact').val(data.contact);
$('#imei').val(data.imei);
$('#model').val(data.model);
$('#color').val(data.color);
$('#pass').val(data.pass);
$('#repairtype').val(data.repairType);
$('#remarks').val(data.remarks);
$('#status').val(data.status);
$('#origin').val(data.origin);
$('#usercode').val(data.usercode);
})
});
I tried the updateorcreate but still the same problem appear.
The error comes from the $location variable. It looks your local database has some data in the "branches" table, but your production database doesn't have.
So, your $location variable is null when read from the database in the Elastic Beanstalk server. Make sure your production database working and has all the data.

Making an OAuth request with Laravel for Stripe

I was translating following PHP code:
$person = \Stripe\Account::createPerson(
'{{CONNECTED_ACCOUNT_ID}}', // id of the account created earlier
[
'person_token' => $token,
]);
To:
$making_user = $stripe->account()->persons()->create(
$request[0], // id of the account created earlier
[
'person_token' => $request[1],
]);
Above Laravel code works find without any issue. Does anyone have any idea that what can be the equivalent Laravel syntax of the following:
$response = \Stripe\OAuth::token([
'grant_type' => 'authorization_code',
'code' => 'ac_123456789',
]);
I'm using following as equivalent, but it is giving me error of invalid method "oauth"
$making_account = $stripe->oauth()->create([
'grant_type' => $request['code'],
'code' => 'ac_123456789',
]);
I'm not finding anywhere its syntax anyone have an idea what will be the Laravel syntax of making Oauth call?
This worked for me.
$stripe = new \Stripe\StripeClient('SECRET_KEY_HERE');
$response = $stripe->oauth->token([
'grant_type' => 'authorization_code',
'code' => 'CODE_HERE'
]);

custom phpbb3 registration

i am making a custom phpbb3 registration and i am trying to register a user form a external file but it not working . also i checked for errors . there is no error .can anyone help me out with where i am wrong . also if anyone has any easy idea how to add a new user record for phpbb3 please help me out with this .
<?php
$username = $_POST[username];
$password = $_POST[password];
$email_address = $_POST[email];
include('forums/common.php');
require('forums/includes/functions_user.php');
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewtopic');
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
$user_row = array(
'username' => $username, //REQUIRED IN FORM
'user_password' => md5($password), //REQUIRED IN FORM
'user_email' => $email_address, //REQUIRED IN FORM
'group_id' => 0,//(int) $group_id,
'user_timezone' => $timezone = date(Z) / 3600,//(float) $data[tz],
'user_dst' => date(I),//$is_dst,
'user_lang' => $user->lang_name,//$data[lang],
'user_type' => USER_NORMAL,//$user_type,
'user_actkey' => '',//$user_actkey,
'user_ip' => $user->ip,
'user_regdate' => time(),
'user_inactive_reason' => 0,//$user_inactive_reason,
'user_inactive_time' => 0,//$user_inactive_time,
);
// Register user...
$user_id = user_add($user_row);
?>
You must define
define('IN_PHPBB', true);
In other case your script will exit immediately in common.php and other required files. You can see
if (!defined('IN_PHPBB'))
{
exit;
}
in every required file

Resources