jeudi 1 août 2019

Mastercard payment in pakistan in laravel application

I am building auction website with laravel. For this website first all the customer need to submit there bid to take part in any auction and after the bid unsuccessful candidate should get back there payment. can you guys tell me is that possible?

i didn't try anything yet.

payment should be accepted by mastercard



via Chebli Mohamed

How to send E-mail without Swiftmailer in laravel 5 Because my server doesn't support it. They recommend me to use outlook instead. How I can do this?

Error! I'm getting Swift_TransportException Connection to tcp://send.one.com:465 Timed Out I triied on other Hosting server it is working. I need help regarding this problem to resolve this issue.



via Chebli Mohamed

Requests in Controller

I'm sending ALL routes through a controller and do a find based on a slug.

If it's not finding a match in the DB in the slug, I'd like my controller to then try hit the next request.

I've tried adding

return $next($request);

But I get an error stating that $next is undefined.

How do I get this to work?

Thanks



via Chebli Mohamed

Class 'Paystack' not found

After following all the direction on git on unicodeveloper/laravel-paystack set up,created paystack.php in config,adding 'Paystack' => Unicodeveloper\Paystack\Facades\Paystack::class in alliases and add class in providers, I still have error Class 'Paystack' not found.

I have tried everything possible but to no avail, I added Unicodeveloper\Paystack\Paystack::genTranxRef() the full path inline in the form and it worked but got a different error 'Non-static method Unicodeveloper\Paystack\Paystack::genTranxRef() should not be called statically'

form input: <input type="hidden" name="reference" value="">

Controller use Illuminate\Http\Request; use \Unicodeveloper\Paystack\Paystack;

use App\Http\Requests; use App\Http\Controllers\Controller;

`class PaymentController extends Controller { /** * Redirect the User to Paystack Payment Page * @return Url */

public function redirectToGateway(Request $request)
{
    $paystack = new Paystack();
    $user = Auth::user();
    $request->email = $user->email;
    $request->orderID = '3';
    $request->amount = '200000';
    $request->quantity = '1';
    $request->reference = $paystack->genTranxRef();
    $request->key = config('paystack.secretKey');
    return $paystack->getAuthorizationUrl()->redirectNow();

} 

/**
 * Obtain Paystack payment information
 * @return void
 */
public function handleGatewayCallback(Request $request)
{
    $paystack = new Paystack();
    $paymentDetails = Paystack::getPaymentData();

    dd($paymentDetails);
    // Now you have the payment details,
    // you can store the authorization_code in your db to allow for      enter code hererecurrent subscriptions
    // you can then redirect or do whatever you want
}

}`



via Chebli Mohamed

Set a foreign key column to nullable in migration

I'm trying to update a foreign key column and set it to nullable in Laravel migration.

CreateArtTable migration:

public function up()
{
    Schema::create('art', function (Blueprint $table) {
        $table->bigIncrements('id')->unsigned();
        $table->bigInteger('item_id')->unsigned()->comment('ItemID');
        $table->foreign('item_id')->references('id')->on('items');
    });
}

public function down()
{
    Schema::dropIfExists('art');
}

Since this is already live and we're doing some updates, we're doing our best not to touch the existing migration files. And here's what I do:

ChangeArticleTableAddNullablesToItemId migration:

   Schema::table('art', function (Blueprint $table) {
       $table->dropForeign('art_item_id_foreign');
       $table->integer('item_id')->nullable()->unsigned()->change();
       $table->foreign('item_id')->references('id')->on('users');
   });

Now when I run php artisan:migrate refresh --seed it returns an error:

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1832 Cannot change column 'item_id': used in a foreign key constraint 'art_item_id_foreign' (SQL: ALTER TABLE art CHANGE item_id item_id INT UNSIGNED DEFAULT NULL COMMENT 'ItemID')

How could I set the foreign key to nullable in migration?



via Chebli Mohamed

Array to string conversion - Validation rule for eloquent

I am trying to validate a field using "in" and then passing an array befored defined. But when creating I get this error

"message": "Array to string conversion",
"exception": "ErrorException",

If I comment out the line where I use the validation, then works. So I am pretty sure the problem is that.

I've seen another related posts, but it didnt work.

Thank you.

CONST ARRAY_EXAMPLES = [
    'example1'  => 0,
    'example2'  => 1,
    'example3'   => 2,
    'example4'  => 3,
    'example5' => 4,
    'example6'  => 5,
];

protected $fillable = [
    'array_example'
];

'array_example' => 'int|in:' .array_values(self::ARRAY_EXAMPLES)



via Chebli Mohamed

laravel with mailgun set up

I read everything I can and looks like I set it up and fill in everywhere according to the docs (and internet) but still cant receive any emails.

I need to use MailGun API so I can send emails from my localhost as well as from the test and prod + because 25 port usually closed.

I filled in everything I can just in case some miracle happen (was changing between smtp/mailgun in .env)

I have tried both my real server settings and when I fail tried without any success sandbox as well.

my mailgun data access (some letters hidden):

  1. my mailgun sandbox server http://i.imgur.com/XCi8Hkn.png

  2. when i click to it i have an option to choose between API and SMTP
    2.1 in API tab i have API KEY: http://i.imgur.com/xGSq7aF.png
    2.2 in SMTP box i have smtp host, port, login, passwd: http://i.imgur.com/t5Pi6lH.png

  3. my .env:
MAIL_DRIVER=mailgun

MAILGUN_DOMAIN=sandbox8ffexxxxxxxxxxxxxad0cf6b4da3c2.mailgun.org
MAILGUN_SECRET=b3ff30bxxxxxxxxxxxxxxxx087d-f877bd7a-01ecceaa

MAIL_HOST=smtp.eu.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster@sandbox8ffexxxxxxxxxxd0cf6b4da3c2.mailgun.org
MAIL_PASSWORD=f5978ef9xxxxxxxxxx5c5312e-f877bd7a-f9cb0e60
MAIL_ENCRYPTION=null

somewhere in internet found that MAILGUN_DOMAIN & MAILGUN_SECRET could be added in .env so tried them here as well

  1. config/mail.php
    'driver' => env('mailgun', 'mailgun'),
    'host' => env('smtp.eu.mailgun.org', 'smtp.mailgun.org'),
    'port' => env('587', 587),
    'from' => [
        'address' => env('support@mail.mydomain.one', 'hello@example.com'),
        'name' => env('mydomain.one Service', 'Example'),
    ],
    'username' => env('postmaster@sandbox8ffexxxxxxxxxxd0cf6b4da3c2.mailgun.org'),

    'password' => env('f5978ef9xxxxxxxxxx5c5312e-f877bd7a-f9cb0e60'),


  1. app/mail/Test.php
    public function build()
    {
        return $this->from('support@mail.mydomain.one')
                    ->view('test');
    }

  1. TestController
use App\Mail\Test;
use Illuminate\Support\Facades\Mail;

class TestController extends Controller
{
    public function test()
    {
        echo 'hello';

        try {
            Mail::to('myaddress@gmail.com')->send(new Test());
        } catch  (\Exception $e) {
            dump($e);
        }

        echo 'hello2';

    }
}


  1. resources/views/test.blade.php
hello

  1. was using even so just in case
> artisan cache:clear
> artisan config:cache
> artisan cache:clear

please help, what is missing ? what i did wrong ?



via Chebli Mohamed