samedi 30 juin 2018

How to use a variable in blade array

How can i use a variable inside a blade array like so

$my_var = 54

array('class'=>'info', 'link'=> '', 'message'=> 'AllRenewals', 'icon'=> 'history')

Laravel seems to not be able to understand its a vairable



via Chebli Mohamed

vendredi 29 juin 2018

Is it better to post json data or just key-value pairs in Laravel Apis?

i have developed the Api in Laravel now one of my team member saying that i will post the data in Json format during api call. now what should i do?

is it better to post data in Json format or just use key-value pairs? please help



via Chebli Mohamed

jeudi 28 juin 2018

Laravel: echo javascript function if a certain session variable is present

Is it possible to do something like this ...

@if(Session::has('foo'))
    <script>
    // My JavaScript function
    </script>
@endif

I am trying to put Facebook pixel code only if a certain session variable is there.

Please advise.



via Chebli Mohamed

lundi 25 juin 2018

Error on trying to apply a subscription to the newly created custome

On the Backend, we are using Laravel 5.1 because the previous developer decided to use this artifact instead of 5.4, which was available at the time of the project creation. To perform the payments, subscriptions, invoices - we are using Billable(Cashier) with Stripe.

The problem is next one, that we are facing this issue only on the Staging (dev) server, but not on the Local environment:

Laravel's Stripe issue on the try to apply the subscription plan to the customer

This is how it was done (sorry for not following PSR. We have no time to refactor, as the client is burning)

    public function postJoin(Request $request)
    {
        $input = $request->all();

        try {
            $this->user->subscription($input['plan'])
                ->create($this->user->setOrGetStripeCustomerId(), [
                    'email' => $this->user->email
                ]);

            $this->user->update(['paid' => true]);

            return redirect('subusers')
                ->with('info', Lang::get('app.membership_active'));

        } catch (Exception $e) {
            return back()->with('info', $e->getMessage());
        }
    }

What can cause this issue?



via Chebli Mohamed

dimanche 24 juin 2018

Laravel required if validation issue

Laravel required if validation issue

Blade:

           
        <div class="form-group row">
            
            <div class="col-md-9">
                
            </div>
        </div>
        <div class="form-group row">
            <label class="col-md-3 col-form-label font-weight-bold">Mandrill</label>
        </div>
        <div class="form-group row">
            
            <div class="col-md-9">
                
            </div>
        </div>
        <div class="form-group row">
            <div class="col-md-9 ml-md-auto">
                
                 <a class="btn btn-danger" href=""><i class="far fa-times-circle"></i> Cancel</a>
            </div>
        </div>
    

Form Request:

    return [
        'driver' => 'required',
        'mailgun.*.domain' => 'required_if:driver,mailgun'
    ];

Validation always fails. Please suggest me if i miss anything.



via Chebli Mohamed

samedi 23 juin 2018

Unable to delete a record when created foreign-key constraints manually in mysql without using migration.

I have created database tables manually and i have also created foreign key constraints in tables manually without using migration. now when i am going to delete a record it giving me following error-

Integrity constraint violation: Cannot delete or update a parent row: a foreign key constraint fails

Note: i can't use migration because database was already created.



via Chebli Mohamed

vendredi 22 juin 2018

error while installing composer and open project

Error when i use this command composer install ,

Fatal error: composerRequire1ee160e16912ab41755f87617b1e4590(): Failed opening required 'C:\xampp\htdocs\try\ytl\vendor\composer/../psy/psysh/src/functions.php' (include_path='C:\xam pp\php\PEAR') in C:\xampp\htdocs\try\ytl\vendor\composer\autoload_real.php on line 66

when i open project in browser : error

Warning: require(C:\xampp\htdocs\try\ytl\vendor\composer/../psy/psysh/src/functions.php): failed to open stream: No such file or directory in C:\xampp\htdocs\try\ytl\vendor\composer\autoload_real.php on line 66

Fatal error: require(): Failed opening required 'C:\xampp\htdocs\try\ytl\vendor\composer/../psy/psysh/src/functions.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\try\ytl\vendor\composer\autoload_real.php on line 66

tired with below command:

composer dump-autoload

below code in vendor/autoload.php:

<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit1ee160e16912ab41755f87617b1e4590::getLoader();



via Chebli Mohamed