Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

dreamxyz

Experience

5,160

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

12th December, 2017

dreamxyz left a reply on How Can I Manage To Get All Of The Foreign Key When Grouping Based On Code And Show In Data Table? • 1 day ago

@Snapey yes, i am storing id_supplier in product table. I able to display it in table by just one row for each item code with it's supplier. I also need the name of supplier as well, but i face problem on separating id and name.

//query
select code, group_concat(s.supplier_id,s.supplier_name) AS supplier_id_name
from catalog c
left join product p on p.product_id= c.product_id
left join supplier s on s.supplier_id = p.product_id
group by code;


//query will show following output

id supplier - 1,  name - abc
id supplier - 2, name - def

Code        | Supplier
A001        | 1abc,2def  // id and name of supplier

What i am expected

Code        | Supplier
A001        | checkboxes value = 1 and then display supplier name beside....... and                     continue in the same row if  more supplier

dreamxyz left a reply on How Can I Manage To Get All Of The Foreign Key When Grouping Based On Code And Show In Data Table? • 1 day ago

@bobbybouwmann I need to show one row only for each item code. I tried use *** group_concat*** to make it, and the sql output display as shown below

    A001 | 1,2

I want to loop it and display in datatable

@foreach($result as $r)

// how can i loop the id_supplier and assign to each checkboxes?

@end for loop

11th December, 2017

dreamxyz started a new conversation How Can I Manage To Get All Of The Foreign Key When Grouping Based On Code And Show In Data Table? • 1 day ago

I have 2 table as shown below

Product table
|---------------------|------------------|------------------|
|    id_product      |  id_supplier   |   name            |   
|---------------------|------------------|------------------|
|          1                 |         1             |      abc              |     
|---------------------|------------------|------------------|
|          2                 |         2                |       acc              |                           
|---------------------|------------------|------------------|

Catalog table
|---------------------|------------------|------------------|
|    id_product      |  id_supplier   |   item code   |   
|---------------------|------------------|------------------|
|          1                 |         1             |      A001            |     
|---------------------|------------------|------------------|
|          2                 |         2                |       A001          |                           
|---------------------|------------------|------------------|

There are 2 supplier which supply the same item, i will assigned them to the same item code. I will write a query to group by item code where i can't get 2 of the id supplier. I want to display the product information and its supplier in dropdown list in datatable. How can i achieve that?

7th December, 2017

dreamxyz started a new conversation What Is Correct Placement Of Js And Css In Blade View? • 6 days ago

In view, where should i place the js and css resources?

@section(content_header)
or
@section(content)
or
// After section content?

How can i determine which js or css should be placed first and after the other?

6th December, 2017

dreamxyz started a new conversation Display Item In Grid View • 1 week ago

I am currently try to display item for user add to cart in grid view. I tried LengthAwarePaginator but when paginate to next pages, very slow and not proper alignment etc. Is there any other method can be used to display item in grid view?

27th November, 2017

26th November, 2017

dreamxyz started a new conversation Trying To Get Non-properties Error While Using Count When Database Return No Result • 2 weeks ago

In my controller

 $results = DB::select($query);

In my blade view

@if(count($results) > 0)
...
@else
No result found.
@endif

I am getting error trying to get non-property object while the query is null. What's the problem?

24th November, 2017

dreamxyz started a new conversation How Can I Manually Increment By Any Number For The Letter Of Alphabet? • 2 weeks ago

$row = 'A';


if($row_a== true){
              $row++;
        }
        if($row_b == true){
           $row++;
        }
        if($row_c == true){

            $row++;
        }
        if($row_d == true){
           $row++;
        }
        if($row_e == true){
            $row++;
        }

I have a condition to hide or show the column, everytime user select then the column will increased by 1 same to alphabet.

Now, user select the value $row_a, then the row will became 'B'. How can i manually let 'B' became 'D' without affect the $row?

dreamxyz started a new conversation How To Set The Grand Total With Col Span Using Maatwebsite/Laravel-Excel? • 2 weeks ago

I pull the data from database and export to xls file, i showed header and content, but how can i include the grand total with colspan based on column to the excel?

// header, content

$someArray = [];$total_qr = "";  $total = "";
            foreach ($results as $key => $r) {
                $row = array();
                $row['No.'] = $key+1;
                foreach($groupOption as $go) {
                    if ($go == 1) {
                        $row['Name'] = $r->name;
                    }
                    if ($go == 2) {
                        $row['Address'] = $r->address;
                    }
                    }

            
                //$row['Total'] =  $r->total;
                   $paArray[] = $row;
            }
   
            
            $today = Carbon::now()->toDateString();
        $myFile=  Excel::create('Report_'. $today, function($excel) use ($someArray )
            {
                $excel->setTitle('Report');
                $excel->sheet('Report', function($sheet) use ($someArray ) {
                    $sheet->fromArray($someArray , null, 'A1', true);
                });
            });
    }

Currently, i sho hw my header and content in excel. Butow can i set e.g. grand total at the end of the content with colspan?? Thanks.

21st November, 2017

dreamxyz left a reply on How To Show Count Of Array In Blade And If Count Equal To 1 Then Show The Value? • 3 weeks ago

@saurabhd For example, i have a dropdown list in my blade, i will select multiple item from the dropdown list. After that, i will pass to my controller and send to another view for printing purpose.

$id_branch = Input::get('id_branch')
$noOfBranch =  count($id_branch);  //to show number of branch selected

i will pass the $noOfBranch to my printing view, to show how many branch being selected at top corner. It works fine for me when branch selected more than one, how if the user only select 1 branch and i want to display the branch name in my printing view?

//when user select more than 1
Branch : 2 selected

//when user select only one
Branch : ABC Company

dreamxyz started a new conversation How To Show Count Of Array In Blade And If Count Equal To 1 Then Show The Value? • 3 weeks ago

$id_branch is used to store dropdown list value.

$id_branch = Input::get('id_branch')
$noBranch =  count($id_branch);

I will pass the count to my blade after that. But how can i show only branch name if only 1 item is selected instead of count as 1?

20th November, 2017

dreamxyz started a new conversation How To Pass Parameter From Controller To Jasper Report? • 3 weeks ago

This is my route

Route::get('/reports', function () {

    $output = public_path() . '/examples/'.time().'_hello_world';
    $report = new JasperPHP;
    $report->process(
        public_path() . '/examples/hello_world.jrxml',
        $output,
        array('pdf', 'rtf', 'xml'),
        array(),
        array()  
        )->execute();
});

How can i pass my parameter to query in jrxml file??

dreamxyz left a reply on Is There Any Report Generator For Laravel? • 3 weeks ago

How do i actually pass the parameter from controller to jasper report?

19th November, 2017

dreamxyz left a reply on Is There Any Report Generator For Laravel? • 3 weeks ago

@tisuchi Is that mean i build my report in jasper studio and integrate report to my apps only?

dreamxyz left a reply on Is There Any Report Generator For Laravel? • 3 weeks ago

@tisuchi The first link seem like fixed template? If using JasperStudio how do i connect the database from phpmyadmin?

dreamxyz left a reply on Is There Any Report Generator For Laravel? • 3 weeks ago

@robrogers3 This is the sample output i want - http://www.basoftware.com.my/wp-content/uploads/2016/01/yearly-purchase-1.png

//css
 @page {

                margin-bottom: 40px;
                counter-increment: page;
                content: "Page " counter(page) " of " counter(pages);

        @bottom-right  {
            border-top: 1px solid #000000;
            padding-right: 20px;
            font-size: 12px !important;

        }
        @bottom-left  {
            content: "Footer content goes here.";
            border-top: 1px solid #000000;
        }

        }

        div#printhead {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 2em;
            text-align: center;
            padding-bottom: 1em;
            border-bottom: 1px solid;
            margin-bottom: 10px;
        }

        div#printhead {
            display: block;
            clear: both;
            text-align: center;
        }

        div#docbody {counter-reset: page;
            margin-top: 3em;
            overflow: visible !important;
            overflow-wrap: break-word;
            page-break-after: auto;
            height: 50px;
        }

        body {

            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .footer {
            width: 100%;
            display: flex;
            margin-top: auto;
            justify-content: space-between;
            bottom: 0px;
            font-size: 12px;
            position: fixed;
        }

        .left {
            width: 15%;
        }

        .footer::after {
            counter-increment: page;
            content: counter(page);
            font-size: 12px;

        }



//sample html
<body>
<div>
    <span>Information:</span><br><span>aaaaa</span>
    <div id="printhead">
        <p>
            This is the print page header
        </p>
    </div>
    </div>
    <div id="docbody" >
       <p>aaaaaaaaaa</p>
        <p>aaaaaaaaaa</p>
        <p>aaaaaaaaaa</p>
        <p>aaaaaaaaaa</p>
        <p>aaaaaaaaaa</p>
        <p>aaaaaaaaaa</p>
        <p>aaaaaaaaaa</p>
.....
    </div>

    <div class="footer">
        <p class="left">this is a footer   Page </p>
        <p class="right"></p>
    </div>
</body>

Header and footer mean every printed page will show header like company name and footer like page 1 of 2 etc.

dreamxyz started a new conversation Is There Any Report Generator For Laravel? • 3 weeks ago

I want to generate a report, i am facing problem if i do it with html where there are header and footer also number of page. Is there any package can generate a custom report?

17th November, 2017

dreamxyz started a new conversation How To Design A Item Sale Analysis Report? • 3 weeks ago

I want to design a item sale analysis report in printable version, is there any good design template for this kind of report?

16th November, 2017

dreamxyz left a reply on How To Find The Checkbox When The Select On Change? • 3 weeks ago

From console.log i can see

//working without selectpicker
//console output
[input, prevObject: n.fn.init(1), context: select#date_filter.dateselectpicker.form-control, selector: ":checkbox"]

//not working with selectpicker
//console output
[prevObject: n.fn.init(0), context: select#date_filter.dateselectpicker.form-control, selector: ":checkbox"]

It cannot detect the previous object if using selectpicker.

dreamxyz left a reply on How To Find The Checkbox When The Select On Change? • 3 weeks ago

@RamjithAp not working, i have no idea why..

dreamxyz started a new conversation How To Find The Checkbox When The Select On Change? • 3 weeks ago

I have multiple group which each of them consist of a checkbox and a dropdownlist which group together, when the dropdown list for the particular group is changed then the checkbox also will automatically set to checked.

 <div class="form-group">
    <div class="input-group col-md-12">
      <span class="input-group-addon">
            <input type="checkbox" name="filter[]" value="1">
          </span>
      <select class="selectpicker form-control" id="filter" title="Filter">
                <option>a</option>
                <option>b</option>
            </select>
    </div>
  </div>

I tried this code not working.

$( "select" ).change(function() {
 $(this).prev(".input-group-addon").find(":checkbox").prop("checked",true);
});

When i removed this only it worked.

 $('.selectpicker').selectpicker();

Can anyone tell me what's wrong with this?

19th October, 2017

dreamxyz started a new conversation Laravel Dompdf Pdf View Different With Chrome Pdf View • 1 month ago

I have generated a pdf using dompdf, but the result is not like what i am expected. The overall content enlarged and different view as like browser view. When i am using google chrome to convert as pdf then it looks just fine, while using dompdf to convert it then it looks terrible.

Can anyone tell me what's problem with this?

17th October, 2017

dreamxyz started a new conversation How To Run Php Artisan Serve And Queue On The Same Time On Cmd? • 1 month ago

I use cmd to run my application, i need to run php artisan serve in order to start my application. I push something into the queue, and i need to use php artisan listen:queue to run the job. Now i need to manually stop application and change command to php artisan listen:queue to perform the job, how can i run the queue automatically whenever there's job stored in database? I also referred to https://laravel.com/docs/5.5/queues#supervisor-configuration but i don't understand how it works. Anyone can guide me? Thanks.

dreamxyz left a reply on How To Use Mail Queue For Send An Email With Pdf Attachment? • 1 month ago

@lancecoder Yes, i tried but seem like not working for me. If got sample then is good, not sure whether i am doing it in wrong way or what.

dreamxyz left a reply on How To Use Mail Queue For Send An Email With Pdf Attachment? • 1 month ago

@christianyeah When i convert a view into pdf it takes about 360 seconds of loading, which is not good.

16th October, 2017

dreamxyz started a new conversation How To Use Mail Queue For Send An Email With Pdf Attachment? • 1 month ago

I tried

Mail::queue(...)

but it just like

Mail::send(...)

It takes very long time to send the email out to user, can i use queue to prevent this issue?Or is there any method i can used to prevent execution time exceeded when sending mail with pdf attachment? Thanks.

dreamxyz left a reply on Is There A Method To Convert A Html Page Into Pdf And Attach Pdf In Email Without Save The Pdf To Storage? • 1 month ago

@tisuchi i get exceeded time when i load the view, how can i solve it? I tried extend the maximum time but not working also. thanks

dreamxyz left a reply on Is There A Method To Convert A Html Page Into Pdf And Attach Pdf In Email Without Save The Pdf To Storage? • 1 month ago

@tisuchi i tried something like

   $pdf = PDF::loadHtml(URL::to(......));
   $m->attachData($pdf->output(), 'abc.pdf', ['mime' => 'application/pdf']);

When email sent out, the attachment is blank and only with the url link, is my way correct to make the html as pdf and send as email attachment?

15th October, 2017

dreamxyz left a reply on Is There A Method To Convert A Html Page Into Pdf And Attach Pdf In Email Without Save The Pdf To Storage? • 1 month ago

@jlrdw Can i convert it and send directly without store the pdf file somewhere else?

dreamxyz started a new conversation Is There A Method To Convert A Html Page Into Pdf And Attach Pdf In Email Without Save The Pdf To Storage? • 1 month ago

I am using this method to send email

Mail::send('....')

I want to convert a html page to pdf format and send via email as attachment. Is there any method i can use for perform this?

13th October, 2017

dreamxyz started a new conversation White Space Occurred When Using Overlay Css By Creating Div To Highlight Element • 2 months ago

This is my css which used to highlight content of page.

overlay { position: absolute; opacity: .3; background: rgba(0,0,0,.8); }

I am using adminlte template and i am adding overlay to certain page then it caused this problem when overlay happened.

//Function to set position

setPosition: function(step, targetBounds){
        // check if step has disabled the highlight:
        if (!this.stepOpts.highlight){
            return;
        }

        var margin = this.stepOpts.highlightMargin;

        var body = document.body,
            html = document.documentElement;

        var documentHeight = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );

        // top div:
        el = this.element.top;
        el.style.top = '0px';
        el.style.left = '0px';
        el.style.width = window.screen.width + 'px';
        el.style.height = targetBounds.top + utils.getScrollTop() - margin + 'px';

        // right div:
        el = this.element.right;
        el.style.top = targetBounds.top + utils.getScrollTop() - margin + 'px';
        el.style.left = targetBounds.left + targetBounds.width + utils.getScrollLeft() + margin + 'px';
        el.style.width = window.screen.width  - (targetBounds.left + targetBounds.width + utils.getScrollLeft() + margin) +  'px';
        el.style.height = targetBounds.height + margin * 2 + 'px';

        // bottom div:
        el = this.element.bottom;
        el.style.top = targetBounds.top + utils.getScrollTop() + targetBounds.height + margin + 'px';
        el.style.left = '0px';
        el.style.width = window.screen.width + 'px';
        el.style.height = documentHeight - (targetBounds.top + utils.getScrollTop() + targetBounds.height + margin) + 'px';

        // left div:
        el = this.element.left;
        el.style.top = targetBounds.top + utils.getScrollTop() + - margin + 'px';
        el.style.left = '0px';
        el.style.width = targetBounds.left + utils.getScrollLeft() - margin + 'px';
        el.style.height = targetBounds.height + margin * 2 + 'px';
    },

The problem caused by the height of the html, any way to solve the problem? The problem caused by the //bottom div

11th October, 2017

dreamxyz started a new conversation Intro.js How To Select Multiple Element, Navigate Between Pages With Continuous Steps? • 2 months ago

I am currently using Intro.js for my website.

//Page 1
    function startIntro(){
            var intro = introJs();

    intro.setOptions({
            steps: [
                {
                element: "#id_supplier",
                //   intro: "This is a dropdown",
                intro:'User click apply <hr><p><b>The tutorial video as shown below:<b></p><iframe class="abcd" src="https://www.youtube.com/embed/EU7PRmCpx-0" frameborder="0" ></iframe>',

            },
            {
                element: ".panel-group",
                intro: "Hello world!",
            },
            {
                element: ".panel-group",
                intro: 'More features, more <span style="color: red;">f</span><span style="color: green;">u</span><span style="color: blue;">n</span>.',
                position: 'left'
            },
            {
                element: '#step4',
                intro: "<span style='font-family: Tahoma'>Another step with new font!</span>",
                position: 'bottom'
            },
            {
                element: '#step5',
                intro: '<strong>Get</strong> it, <strong>use</strong> it.'
            }
        ]
});

intro.onchange(function(element) {
     if (this._currentStep === 0) {

     $("#id_supplier")[0].selectedIndex = 1;
         $("#id_supplier").trigger('change');
     }
     else{
        window.location.href= "/index?multipage=true";
     }
});
        intro.start();
};

$('#info').click(function () {
        startIntro();
})

How can i make it to select multiple element? E.g. select the same class name

//Page 2
 if (RegExp('multipage', 'gi').test(window.location.search)) {

        var intro = introJs();

        intro.setOptions({
            steps: [
                {
                    intro:'User click apply <hr><p><b>The tutorial video as shown below:<b></p><iframe class="abcd" src="https://www.youtube.com/embed/EU7PRmCpx-0" frameborder="0" ></iframe>',

                },
                {
                    element: "#create",
                    intro: "Hello world!",
                },
                {
                    element: ".panel-group",
                    intro: 'More features, more <span style="color: red;">f</span><span style="color: green;">u</span><span style="color: blue;">n</span>.',
                    position: 'left'
                }            
            ]
        });

        intro.start();
    }

When go to next page, how can i return back to previous page and the step is continuing from previous page? E.g. Page 1 - Step 1- Step 3, when redirect to Page 2 then the step will start from 4.

Anyone know the solution for this problem? Thanks in advanced.

2nd October, 2017

dreamxyz started a new conversation How To Generate A Unique Id Based On Own Format? • 2 months ago

I have a table as shown below

| id         | id_p       | doc_no       |
|:-----------|------------:|:------------:|
| 1           | 1             |     D11710001
| 2          | 2            |     D21710001
| 3          | 3            |     D31710001
| 4          | 4           |     D41710001
| 5          | 5            |     D51710001
| 6          | 1            |     D11710002

I want to generate an unique id based on the id given. For example, when i have item to be stored in this table, it will generate an unique id based on the id of the table.

Note: The id in this table is a foreign key. The doc no can be modified by user into their own format manually. The doc no only will be generated automatically when user does not input a value to the doc no field.

The id format - P 'id' 'month' 'day' 001(auto increment)

How can i query this to generate unique id during storing data?

22nd September, 2017

dreamxyz left a reply on How To Pass An Array To Ajax And Accessible In Controller? • 2 months ago

I can't get it. This is how my controller function 1 look like

// this is the array get from dropdown list
 $categoryOption = Input::get('categoryOption'); 

.....

return View::make('view2')->with($categoryOption);
 

When in view2, user click a button and will call controller function 2

return View::make('view3')..;

In view2 i need to get the $categoryOption array value from function 1. How can i make it works?

dreamxyz left a reply on How To Pass An Array To Ajax And Accessible In Controller? • 2 months ago

@vanderb E.g. i have a dropdownlist from view1 which allow multiselect, after that using query builder to filter data based on the dropdown selection and then return to view2. In view2, i need to get the dropdown selection from view 1 for the ajax call for printing. This is why actually i want to do this.

dreamxyz left a reply on How To Pass An Array To Ajax And Accessible In Controller? • 2 months ago

@vanderb Can i ask, is that possible to pass an array return from view1 controller to view 2 and then from view 2 pass it to another controller?

dreamxyz started a new conversation How To Pass An Array To Ajax And Accessible In Controller? • 2 months ago

I have an array

[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]

How can i pass this array to ajax and get it from controller?

  $(document).on('click', '#print', function(){
        var code = $(this).attr('data-code');
        $.ajax({
            type: 'GET',
            url: 'print',
            data: {code: code,option: array here},
            dataType: 'html',
            success: function (html) {
                w = window.open(window.location.href,"_blank");
                w.document.open();
                w.document.write(html);
                w.document.close();
            },
            error: function (data) {
                console.log('Error:', data);
            }
        });
    });

In controller

Input::get('option');

20th September, 2017

dreamxyz left a reply on How Can I Store An Multiselection From A Dropdown List And Allow Accessible From Multiple View? • 2 months ago

@tisuchi Thanks, the alternative method is working fine. Just want get to know, is it necessary to loop it in order to get the value?

dreamxyz left a reply on How Can I Store An Multiselection From A Dropdown List And Allow Accessible From Multiple View? • 2 months ago

@tisuchi but i will get this error if i do it like this

htmlspecialchars() expects parameter 1 to be string, array given

Error caused by

<input type="hidden" value="{{$option}} "name="option"/>

dreamxyz left a reply on How Can I Store An Multiselection From A Dropdown List And Allow Accessible From Multiple View? • 2 months ago

@tisuchi Sorry, maybe my question not clear. What i mean is, when i get the selection from view1 and pass the multiple select value to controller. From the controller function, i will return to view2. In view2 i need to get the array value from the dropdownlist where i passed from view1 to controller. How could i get the value in view2 for ajax purpose?

19th September, 2017

dreamxyz started a new conversation How Can I Store An Multiselection From A Dropdown List And Allow Accessible From Multiple View? • 2 months ago

I have a dropdown list like

<select class="selectpicker form-control" data-live-search="true" title="Select branch" name="id_branch" id="id_branch" required>
@foreach($branches as $branch)
<option value="{{$branch->id_branch}}">{{ $branch->branch_name }}</option>
@endforeach

In controller, i will get the selection and do filtering

$id= Input::get('id_branch');

After that return to another page for printing purpose. When i click on the print button, how can i get the selection from dropdownlist and pass the selection through ajax?

dreamxyz started a new conversation Datatable Row Grouping Function • 2 months ago

How to sum up the textbox value in datatable while using row grouping function? The code below is worked when the column is not a textbox. How can i get the value from textbox and sum it up by using the following code?

$('#myTable').DataTable( {
order: [[2, 'asc']],
rowGroup: {
    startRender: null,
    endRender: function ( rows, group ) {
         var ageAvg = rows
            .data()
            .pluck(3)
            .reduce( function (a, b) {
                return a + b*1;
            }, 0) / rows.count();

        var salaryAvg = rows
            .data()
            .pluck(5)
            .reduce( function (a, b) {
                return a + b.replace(/[^\d]/g, '')*1;
            }, 0) / rows.count();
        salaryAvg = $.fn.dataTable.render.number(',', '.', 0, '$').display( salaryAvg );

        return $('<tr/>')
            .append( '<td colspan="3">Averages for '+group+'</td>' )
            .append( '<td>'+ageAvg.toFixed(0)+'</td>' )
            .append( '<td/>' )
            .append( '<td>'+salaryAvg+'</td>' );
    },
    dataSrc: 2
   }
});

I tried to get the value from the column if the column is a textbox and it is not working with the code above, it only works if it is a text. What possible way i can use to get the value from textbox.

18th September, 2017

dreamxyz started a new conversation Can I Pass Array Get An Input Field To Another View Without Looping It? • 2 months ago

I want to pass an array get from the dropdown list to another view without looping it. For example, in view1, i get the value from dropdownlist.

// all the branch id get from selection.
$id_branch = Input::get('id_branch');

And in controller pass it to another view

 return View::make('pages.report')->with('id_branch');
  

From the view2, when i press the button, it will pass this array to the controller to filter data. Is that possible to make it?

15th September, 2017

dreamxyz left a reply on How To Pass The Array Value Into Raw Query? • 2 months ago

To make it work, just do in this way, am i right?

 ->leftJoin('sb_item_code', 'sb_item_code.id_product','=','catalogs.id_product')
 ->where('sb_item_code.stock_date',$dateOption)
 ->where('sb_item_code.period',$scOption)

dreamxyz left a reply on How To Pass The Array Value Into Raw Query? • 2 months ago

At least i need get to know what the problem before moving on. If without where clause inside the leftjoin subquery then it worked, else returned null value for all the field from the subquery table.

dreamxyz left a reply on How To Pass The Array Value Into Raw Query? • 2 months ago

@tisuchi Relationships between tables are defined, but not sure how it works. So, i use my own way to do it. The query should be working fine, but during leftJoin sb_item_code table, the value for the field returned null value. No idea haha.

dreamxyz left a reply on How To Pass The Array Value Into Raw Query? • 2 months ago

@tisuchi Do you mean something like this?

$productLists = Catalog::leftJoin('products','catalogs.id_product', '=', 'products.id_product')

                      //  ->leftJoin('products', 'catalogs.id_product', '=', 'products.id_product')
                       // ->leftJoin($sbb, 'catalogs.id_product', '=', 'sbb.id_product')
                        ->leftJoin(DB::raw('(Select sb.* from sb_item_code sb where sb.stock_date='.$dateOption.' AND sb.period ='.$scOption.') as sbb'),function($join){
                           $join->on("sbb.id_product","=","catalogs.id_product");
                        })
                        ->leftJoin('categories', 'products.id_category', '=', 'categories.id_category')
                        ->where('catalogs.id_branch',Auth::user()->id_branch)
                        ->whereIn('products.id_category',$categoryOption)
                        ->whereIn('products.id_supplier',$supplierOption)
                        ->where('catalogs.catalog_tags','like','%'.$tags.'%')
                        ->where('catalogs.catalog_status',1)
                        ->where('catalogs.wm_stock_count',1)
                        ->orderBy('categories.category_name','asc')
                        ->orderBy('catalogs.catalog_tags','asc')
                        ->orderBy('products.product_name','asc')
                        ->select('sbb.*','products.*','categories.*','catalogs.*')
                        ->get();

dreamxyz left a reply on How To Pass The Array Value Into Raw Query? • 2 months ago

@tisuchi Can i know what's wrong between this 2 query? I am having some problem after modify, where field from sb_item_code return null value.

// Expected query 
$sql = 'SELECT sbb.*, p.*
                            FROM catalogs c
                            LEFT JOIN products p on c.id_product = p.id_product
                            LEFT JOIN (SELECT sb.* FROM sb_item_code sb WHERE sb.stock_date = "'.$dateOption.'" AND sb.period = '.$scOption.'
                            ) as sbb on sbb.id_product = c.id_product
                            WHERE c.id_branch = '.Auth::user()->id_branch.'
                            AND c.catalog_status = 1 AND c.wm_stock_count = 1
                            ';

Modified

 $sbb = DB::raw('(Select sb.* from sb_item_code sb where sb.stock_date='.$dateOption.' AND sb.period ='.$scOption.') as sbb');

                    $productLists = DB::table('catalogs')
                        ->leftJoin('products', 'catalogs.id_product', '=', 'products.id_product')
                        ->leftJoin($sbb, 'sbb.id_product', '=', 'catalogs.id_product')
                        ->leftJoin('categories', 'products.id_category', '=', 'categories.id_category')
                        ->where('catalogs.id_branch',Auth::user()->id_branch)
                        ->whereIn('products.id_category',$categoryOption)
                        ->whereIn('products.id_supplier',$supplierOption)
                        ->where('catalogs.catalog_tags','like','%'.$tags.'%')
                        ->where('catalogs.catalog_status',1)
                        ->where('catalogs.wm_stock_count',1)
                        ->orderBy('categories.category_name','asc')
                        ->orderBy('catalogs.catalog_tags','asc')
                        ->orderBy('products.product_name','asc')
                        ->select('sbb.*','products.*','categories.*','catalogs.*')
                        ->get();

Am i doing it in wrong way?

14th September, 2017

dreamxyz left a reply on How To Pass The Array Value Into Raw Query? • 2 months ago

@tisuchi Yeah, i know this. But just want get to know is that possible for raw query?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.