mercredi 25 janvier 2017

Get only specific record from Laravel query "with"

I have a query in laravel like this.

$campaigns =  Cagn::where('status','!=',0)->where('status','!=',3)
    ->select('id','name', 'ad_id', 'status',  'priority',
        DB::raw('(SELECT count FROM lecounts WHERE campaign_id = campaigns.id AND affiliate_id IS NULL) AS lcount'))
    ->orderBy('priority','ASC')
    ->with(['filter_groups'=> function ($q) {
        //$q->select('id', 'status')->where('status', 1)->with('filters');
        $q->where('status', 1)->with('filters');
    }])
    ->with('config')//this is the problem
    ->get();


Array
(
[0] => Array
    (
        [id] => 6
        [name] =>  (951)
        [advertiser_id] => 36
        [status] => 2
        [lead_cap_type] => 1
        [lead_cap_value] => 4
        [default_received] => 0.1
        [default_payout] => 0.1
        [priority] => 1
        [campaign_type] => 1
        [linkout_offer_id] => 0
        [lead_count] => 0
        [filter_groups] => Array
            (
                [0] => Array
                    (
                        [id] => 57
                        [campaign_id] => 6
                        [name] => group222
                        [description] => g111
                        [status] => 1
                        [created_at] => 2016-11-11 01:00:32
                        [updated_at] => 2016-11-11 04:03:42
                        [filters] => Array
                            (
                                [0] => Array
                                    (
                                        [id] => 52
                                        [group_id] => 57
                                        [filter_type_id] => 15
                                        [value_text] => 434
                                        [value_min_integer] => 
                                        [value_max_integer] => 
                                        [value_min_date] => 
                                        [value_max_date] => 
                                        [value_min_time] => 
                                        [value_max_time] => 
                                        [value_boolean] => 
                                        [value_array] => 
                                        [created_at] => 2016-11-11 01:02:19
                                        [updated_at] => 2016-11-11 01:02:19
                                    )

                                [1] => Array
                                    (
                                        [id] => 53
                                        [group_id] => 57
                                        [filter_type_id] => 8
                                        [value_text] => dededed
                                        [value_min_integer] => 
                                        [value_max_integer] => 
                                        [value_min_date] => 
                                        [value_max_date] => 
                                        [value_min_time] => 
                                        [value_max_time] => 
                                        [value_boolean] => 
                                        [value_array] => 
                                        [created_at] => 2016-11-11 01:02:50
                                        [updated_at] => 2016-11-11 01:03:31
                                    )

                            )

                    )

                [1] => Array
                    (
                        [id] => 58
                        [c_id] => 6
                        [name] => g2222222211
                        [description] => g222
                        [status] => 1
                        [created_at] => 2016-11-11 01:00:49
                        [updated_at] => 2016-11-11 04:04:21
                        [filters] => Array
                            (
                                [0] => Array
                                    (
                                        [id] => 55
                                        [group_id] => 58
                                        [filter_type_id] => 32
                                        [value_text] => MustInactive
                                        [value_min_integer] => 
                                        [value_max_integer] => 
                                        [value_min_date] => 
                                        [value_max_date] => 
                                        [value_min_time] => 
                                        [value_max_time] => 
                                        [value_boolean] => 
                                        [value_array] => 
                                        [created_at] => 2016-11-15 02:44:21
                                        [updated_at] => 2016-11-15 02:44:21
                                    )

                            )

                    )

            )

        [config] => Array
            (
                [id] => 6
                [post_url] => http://p/fake_advertiser.php
                [post_url_backup] => http://www.com/coreg
                [post_header] => no post header needed
                [post_data] => {"rev_tracker_map":"aff","rev_tracker":"saff","eiq_email":"em","first_name":"fn","last_name":"ln","ip":"ip","today":"dj","dob":"dob"}
                [post_data_fixed_value] => {"sn":"iq.com"}
                [post_data_map] => {"rev_tracker_map":{"default":"557","CD133":"711","CD165":"711","CD169":"557","CD74":"711","CD7612":"711","CD7635":"711","CD7637":"711","CD98":"711","CD141":"711","CD7654":"711","CD7665":"711","CD7670":"711","CD7672":"711","CD7673":"711","CD7674":"711","CD7676":"711","CD7678":"711","CD7680":"711",688":"711","CD7703":"711","CD7704":"711","CD7708":"711","CD7713":"711","CD7707":"711","CD7712":"711","CD7714":"711","CD7716":"711","CD7717":"711","CD7719":"711","CD7720":"711","CD7721":"711","CD7726":"711","CD7727":"711","CD7730":"711","CD7731":"711","CD7738":"711","CD7757":"711","CD7761":"711"}}
                [post_method] => GET
                [post_success] => Successful
                [ping_url] => http:/c.com/
                [ping_success] => subscribable
                [created_at] => 2015-11-16 14:12:34
                [updated_at] => 2016-02-29 16:40:32
                [ping_header] => 
            )

    )
)

This is my problem

   [config] => Array
        (
            [id] => 6
            [post_url] => http://p/fake_advertiser.php
            [post_url_backup] => http://www.com/coreg
            [post_header] => no post header needed
            [post_data] => {"rev_tracker_map":"aff","rev_tracker":"saff","eiq_email":"em","first_name":"fn","last_name":"ln","ip":"ip","today":"dj","dob":"dob"}
            [post_data_fixed_value] => {"sn":"engageiq.com"}
            [post_data_map] => {"rev_tracker_map":{"default":"557","CD133":"711","CD165":"711","CD169":"557","CD74":"711","CD7612":"711","CD7635":"711","CD7637":"711","CD98":"711","CD141":"711","CD7654":"711","CD7665":"711","CD7670":"711","CD7672":"711","CD7673":"711","CD7674":"711","CD7676":"711","CD7678":"711","CD7680":"711","CD7688":"711","CD7703":"711","CD7704":"711","CD7708":"711","CD7713":"711","CD7707":"711","CD7712":"711","CD7714":"711","CD7716":"711","CD7717":"711","CD7719":"711","CD7720":"711","CD7721":"711","CD7726":"711","CD7727":"711","CD7730":"711","CD7731":"711","CD7738":"711","CD7757":"711","CD7761":"711"}}
            [post_method] => GET
            [post_success] => Successful
            [ping_url] => http:/c.com/
            [ping_success] => subscribable
            [created_at] => 2015-11-16 14:12:34
            [updated_at] => 2016-02-29 16:40:32
            [ping_header] => 
        )

I just want to display two something like this

 [config] => Array
        (
            [ping_url] => http:/c.com/
            [ping_success] => subscribable

        )



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire