mercredi 24 janvier 2018

Sphinx indexer does not fetch data when MySQL transaction is used

please help me with running phpunit tests that check module with sphinx search engine.

To search in that module I use two sphinx indexes docs and docsdelta. After new data are appear in the DB, I do following:

exec("indexer docsdelta --rotate");
exec("indexer --merge docs docsdelta --rotate");

It works well on my website and I am able to add new document through the web interface and it appears in the search.

On the same time when I run phpunit test and it creates new document "on fly",

exec("indexer docsdelta --rotate");

does not fetch any new data. My phpunit tests use transactions to rollback the database to the previous state and I notice, that indexer works properly in case if I switch off transactions. Additionally I am able to see new data in the DB, just before and after running indexer. Maybe I missed something but I do not understand why transaction has an influence on indexer.

Is it some way to use indexer docdelta together with MySQL transaction?

Thank you in advance for help!



via Chebli Mohamed

jeudi 18 janvier 2018

With chrisbjr/api-guard how do I turn off it auth for a subset of routes

Under Laravel 5.1

How do I turn off api-guard for certain routes and turn it on for others. We're building an app that needs REST API as well as standard web stuff.

We'd like mobile users to be able to log in and get their auth key, then use that for subsequent auth'd calls. Non mobile users to utilize the Laravel auth that comes out of the box.



via Chebli Mohamed

mardi 16 janvier 2018

Send Mail not working in Laravel 5.1

I have created one demo for sending mail. I am sending mail in contact page it is working. But When I use dynamic email for TO, then it is not working.

Not Working

Mail::send('emails.otp_mail_format',['otp'=>'123456'], function($message){ $message->from('no-reply@example.com'); $message->to($uEmailAddress)->subject('Account Verification'); });

But Working below code

Mail::send('emails.otp_mail_format',['otp'=>'123456'], function($message){ $message->from('no-reply@example.com'); $message->to('kanu@example.come')->subject('Account Verification'); });



via Chebli Mohamed

vendredi 12 janvier 2018

Multidimensional Array Laravel

I'm new to laravel and I'm trying to loop through this multidimensional array in the view of blade template but unable to get the elements. I tried using nested foreach but that doesn't work. I'm unsure what else to do. Please help

Array
(
[2] => Illuminate\Support\Collection Object
    (
        [items:protected] => Array
            (
            )

    )

[3] => Illuminate\Support\Collection Object
    (
        [items:protected] => Array
            (
                [0] => stdClass Object
                    (
                        [ActivityID] => 1
                        [WaiverID] => 3
                        [ProgramID] => 1
                        [ActivityName] => Waiver3 Activity 1
                        [WaiverName] => Waiver 3
                        [ID] => 3
                        [WaiverDescription] => 
                        [ProgramID] => 1
                    )

                [1] => stdClass Object
                    (
                        [ActivityID] => 2
                        [WaiverID] => 3
                        [ProgramID] => 1
                        [ActivityName] => Waiver3 Activity 2
                        [WaiverName] => Waiver 3
                        [ID] => 3
                        [WaiverDescription] => 
                        [ProgramID] => 1
                    )

                [2] => stdClass Object
                    (
                        [ActivityID] => 3
                        [WaiverID] => 3
                        [ProgramID] => 1
                        [ActivityName] => Waiver3 Activity 3
                        [WaiverName] => Waiver 3
                        [ID] => 3
                        [WaiverDescription] => 
                        [ProgramID] => 1
                    )

            )

    )

)

When I do a foreach like this

@foreach ($waiverActivityforTable as$waiverActivityforTableValue)           
    
@endforeach

I get:

[] [] [{"ActivityID":1,"WaiverID":3,"PHAProgramID":1,"ActivityName":"Waiver3 
Activity 1","HCVWaiverName":"Waiver 
3","ID":3,"HCVWaiverDescription":null,"phaProgramID":1},
{"ActivityID":2,"WaiverID":3,"PHAProgramID":1,"ActivityName":"Waiver3 
Activity 2","HCVWaiverName":"Waiver 
3","ID":3,"HCVWaiverDescription":null,"phaProgramID":1},
{"ActivityID":3,"WaiverID":3,"PHAProgramID":1,"ActivityName":"Waiver3 
Activity 3","HCVWaiverName":"Waiver 
3","ID":3,"HCVWaiverDescription":null,"phaProgramID":1}] 

Tired nested foreach: I tried:

    @foreach ($waiverActivityforTable as $waiverActivityforTableValue)
        @foreach ($waiverActivityforTableValue as $test)
            
        @endforeach
    @endforeach

but I get an error: htmlspecialchars() expects parameter 1 to be string, object given



via Chebli Mohamed

jeudi 11 janvier 2018

Queuing mail with attachData in Laravel 5.1 / OctoberCMS

The following IS working when I use Mail::send

$email = 'my@email.com';
$name = 'My Name';
$invoice = InvoicePdf::generate($invoice_id); // generates PDF as raw data

Mail::send('mail.template', null, function($message) use ($name, $email, $invoice) {

    $message->to($email, $name);
    $message->subject('Thank you for your order!');
    $message->attachData($invoicePdf, 'invoice.pdf', ['mime' => 'application/pdf']);

});

It works fine and an email is generated with the correct PDF attachment.

However, if I change Mail::send to Mail::queue then I receive the following error:

Unable to JSON encode payload. Error code: 5

/var/www/html/october/vendor/laravel/framework/src/Illuminate/Queue/Queue.php line 90

If I take the $message->attachData(); line out then it works even with Mail::queue so it seems like the raw data from the attachment is causing issues with the queue but there's nothing in the relevant October or Laravel docs about how to deal with this.



via Chebli Mohamed

mercredi 10 janvier 2018

Auth login issue with different table name and different field

I have user table. That name is tb_users. The field is user_name, user_email, user_pwd, remember_token etc.

I have changed in auth.php

  protected $table = 'mb_uzer181006';

  protected $fillable = ['user_name', 'user_email', 'user_pwd'];

  protected $hidden = ['user_pwd', 'remember_token'];

ErrorException in EloquentUserProvider.php line 112:

Undefined index: password

I am not sure how I will solve this problem. I want to learn auth login with a different field name not same same Users table



via Chebli Mohamed

mardi 9 janvier 2018

Datagrid - both condition branches fire

I have a following code:

public function index(ArticleRepository $articleRepository)
    {
        $this->authorize($this->prefix());
        $filterCategory = Request::get('category');

        if (!Request::ajax()) {
            // Then just return main index admin template, that will ajax-load the data
            return View::make($this->prefix('index'))
                ->with("dataSource", URL::route($this->prefix('index')));
        } else {
            // We'll use DataGrid to display admin listing, first define some basic settings
            $columns = array(
                'id',
                'title',
                'slug',
                'published',
                'translations',
                'cities',
                'faqs',
                'articleCategories',
            );
            $settings = array(
                'sort' => 'id',
                'direction' => 'asc',
                'max_results' => 20
            );

            $commonHandler = $this->articleRepo->filteredData($filterCategory);
            // And finally return DataGrid instance, that will handle all
            return DataGrid::make($commonHandler, $columns, $settings);
        }
    }

The thing that I am curious about is that the both - if and also the else part of code is fired. I guess there are maybe some redirect or something. I am not sure how the datagrid works but when I put the dd(Request::get('category')) to the if(!Request::ajax()) branch I get the data from the Url I am expecting but when I put that code to the else branch I get null. My question is why the both branches fire and if it is caused just by some redirect how do I pass these data (Reqest::get('category')) to the else branch.



via Chebli Mohamed