mardi 2 mars 2021

Creating array variable in collection loop

I get data from query and running a foreach loop on it.

foreach($result as $data)
{
    $myVar[$data->flag][$data->year]['totalActions'] += $data->totalActions;
}

And getting this error Undefined variable: myVar

When I create a variable before loop like $myVar = []

Then it gives me the error Undefined index: All

Here All is value of $data->flag

How to handle this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3q8L7eM
via IFTTT

ReflectionException (-1) Class VoyagerAuth does not exist - Laravel

I am working on a laravel app, and when I run php artisan serve I get this error:

 ReflectionException (-1)
Class VoyagerAuth does not exist


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dXAYiI
via IFTTT

ErrorException: Undefined index: data in ../app/Widgets/TopMenu.php:23

I'm getting this error stating undefined index 'data' at line 26, I've tried to use isset on top but nothing to avail. Any help highly appreciated.

    class TopMenu extends AbstractWidget {
    /**
     * Treat this method as a controller action.
     * Return view() or other content to display.
     */
    public function run()
    {

       $SDKInstance = new BlackLabelSdk();
       $listFilter = $SDKInstance->getFilterList();
       
    return view("widgets.top_menu", [
            'categories' => Categorymodel::archives(),
            'blacklabelFilter' => $listFilter['data']['categories']
    ]);
    
    }
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3rdMnPa
via IFTTT

How to create a unit tests in laravel project

Can somebody clarify, please I m trying to set up unit tests in laravel project Let me explained This is my first experience of learning the unit tests First of all, I was create CRUD`s functions in UserController And now I want to test all these methods The problem that I was getting an error at LengthAwarePaginator If someone knows how to resolve this error I m was so grateful I attached few screenshots please check it

https://prnt.sc/10b4q65

https://prnt.sc/10b4r0p

https://prnt.sc/10b4rp3

https://prnt.sc/10b4swi



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Oce1O3
via IFTTT

lundi 1 mars 2021

Laravel working after I deleted .env file and clear config class

I deleted .env file and clear config class and the application is working perfect. In my opinion laravel will look for env file and create errors. But it is working perfect. How is that happening?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3bVxzyj
via IFTTT

Php artisan get ErrorExecption: Array offset null

Can someone help me ? when i'm try any command artisan always get this error in some project i've downloaded:

In ServiceProvider.php line 84
 Trying to access array offset on value of type null

At first, i get similiar error like this(Laravel php artisan doesn't work)



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3rbKfaD
via IFTTT

how can I pass the 'customer address' to my new Mailer instance?

I am making a dynamic sender, I put this code in a Service class**(AppServiceProvider.php)** or in a function that returns the Mailer object ready to be used.

 public function register()
{
    $this->app->bind('user.id', function ($app, $parameters) {
        $smtp_host = array_get($parameters, 'smtp_host');
        $smtp_port = array_get($parameters, 'smtp_port');
        $smtp_username = array_get($parameters, 'smtp_username');
        $smtp_password = array_get($parameters, 'smtp_password');
        $smtp_encryption = array_get($parameters, 'smtp_encryption');
      
        $from_email = array_get($parameters, 'from_email');
        $from_name = array_get($parameters, 'from_name');
      
        $from_email = $parameters['from_email'];
        $from_name = $parameters['from_name'];
      
        $transport = new \Swift_SmtpTransport($smtp_host, $smtp_port);
        $transport->setUsername($smtp_username);
        $transport->setPassword($smtp_password);
        $transport->setEncryption($smtp_encryption);
      
        $swift_mailer = new \Swift_Mailer($transport);
      
        //$mailer = new Mail;
        $mailer = new Mailer($app->get('view'), $swift_mailer, $app->get('events'));
        $mailer->alwaysFrom($from_email, $from_name);
        $mailer->alwaysReplyTo($from_email, $from_name);
      
        return $mailer;
    });
}

this is my controller where I pass the arguments to the new instance 'mailer'.

public function email(DocumentEmailRequest $request)
{
    $user = Company::active();
    $company = Company::active();
    $document = Document::find($request->input('id'));
    $customer_email = $request->input('customer_email');

    $configuration = [
        'smtp_host'    => 'smtp.gmail.com',
        'smtp_port'    => '465',
        'smtp_username'  => 'email@gmail.com',
        'smtp_password'  => 'password',
        'smtp_encryption'  => 'ssl',
       
        'from_email'    => 'email@gmail.com',
        'from_name'    => 'name',
       ];
       
    $mailer = app()->makeWith('user.id', $configuration);
    
    $mailer->to($customer_email)->send(new DocumentEmail($company, $document));

        return [
        'success' => true
    ];
}

I get this error:

"Swift_RfcComplianceException" exception. line: 355 message: "The given mailbox address [] does not comply with RFC 2822, 3.6.2.


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3uGAX8J
via IFTTT