How to Search With Vendor Name As Well?










2















I'm using Laravel 5.7 & VueJs 2.5.* ...



I have a table with invoice data in it and a invoice is related to the vendor so i also displayed the vendor name in the table, i'm using search feature it works when i search invoice number, but when i want to search with vendor name, its not working.



i did something like this:



I DID THIS IN SCRIPT



mounted() {
Fire.$on("searching", () =>
let query = this.$parent.search;
axios
.get("api/findVTI?q=" + query)
.then(data =>
this.ticketInvoices = data.data;
)
.catch();
);



I MADE A ROUTE





Route::get('findVTI', 'APITicketInvoiceController@searchVTI');




IN MY INVOICE CONTROLLER I DID THIS





 public function searchVTI()

if($search = Request::get('q'))
$VTI = TicketInvoice::where(function($query) use ($search)
$query->where('ticket_invoice_no','LIKE',"%$search%")
->orWhere('ticket_invoice_grand_total','LIKE',"%$search%")
->orWhere('vendor_company_name','LIKE',"%$search%");
)->paginate(10);
else
return TicketInvoice::paginate(10);

return $VTI;




When i write this line:
->orWhere('vendor_company_name','LIKE',"%$search%"); i got an error in console that, vendor_company_name does not exist in ticket_invoices.



I play around with many thing but didn't succeed...



Image For Better Understanding:
enter image description here










share|improve this question






















  • obviously the column is NOT named vendor_company_name maybe it is named related_vendor instead?

    – Nikos M.
    Nov 15 '18 at 19:32











  • @NikosM. I resolved my issue by the answer below Thanks for your support.

    – Saif Zakir
    Nov 15 '18 at 22:43















2















I'm using Laravel 5.7 & VueJs 2.5.* ...



I have a table with invoice data in it and a invoice is related to the vendor so i also displayed the vendor name in the table, i'm using search feature it works when i search invoice number, but when i want to search with vendor name, its not working.



i did something like this:



I DID THIS IN SCRIPT



mounted() {
Fire.$on("searching", () =>
let query = this.$parent.search;
axios
.get("api/findVTI?q=" + query)
.then(data =>
this.ticketInvoices = data.data;
)
.catch();
);



I MADE A ROUTE





Route::get('findVTI', 'APITicketInvoiceController@searchVTI');




IN MY INVOICE CONTROLLER I DID THIS





 public function searchVTI()

if($search = Request::get('q'))
$VTI = TicketInvoice::where(function($query) use ($search)
$query->where('ticket_invoice_no','LIKE',"%$search%")
->orWhere('ticket_invoice_grand_total','LIKE',"%$search%")
->orWhere('vendor_company_name','LIKE',"%$search%");
)->paginate(10);
else
return TicketInvoice::paginate(10);

return $VTI;




When i write this line:
->orWhere('vendor_company_name','LIKE',"%$search%"); i got an error in console that, vendor_company_name does not exist in ticket_invoices.



I play around with many thing but didn't succeed...



Image For Better Understanding:
enter image description here










share|improve this question






















  • obviously the column is NOT named vendor_company_name maybe it is named related_vendor instead?

    – Nikos M.
    Nov 15 '18 at 19:32











  • @NikosM. I resolved my issue by the answer below Thanks for your support.

    – Saif Zakir
    Nov 15 '18 at 22:43













2












2








2








I'm using Laravel 5.7 & VueJs 2.5.* ...



I have a table with invoice data in it and a invoice is related to the vendor so i also displayed the vendor name in the table, i'm using search feature it works when i search invoice number, but when i want to search with vendor name, its not working.



i did something like this:



I DID THIS IN SCRIPT



mounted() {
Fire.$on("searching", () =>
let query = this.$parent.search;
axios
.get("api/findVTI?q=" + query)
.then(data =>
this.ticketInvoices = data.data;
)
.catch();
);



I MADE A ROUTE





Route::get('findVTI', 'APITicketInvoiceController@searchVTI');




IN MY INVOICE CONTROLLER I DID THIS





 public function searchVTI()

if($search = Request::get('q'))
$VTI = TicketInvoice::where(function($query) use ($search)
$query->where('ticket_invoice_no','LIKE',"%$search%")
->orWhere('ticket_invoice_grand_total','LIKE',"%$search%")
->orWhere('vendor_company_name','LIKE',"%$search%");
)->paginate(10);
else
return TicketInvoice::paginate(10);

return $VTI;




When i write this line:
->orWhere('vendor_company_name','LIKE',"%$search%"); i got an error in console that, vendor_company_name does not exist in ticket_invoices.



I play around with many thing but didn't succeed...



Image For Better Understanding:
enter image description here










share|improve this question














I'm using Laravel 5.7 & VueJs 2.5.* ...



I have a table with invoice data in it and a invoice is related to the vendor so i also displayed the vendor name in the table, i'm using search feature it works when i search invoice number, but when i want to search with vendor name, its not working.



i did something like this:



I DID THIS IN SCRIPT



mounted() {
Fire.$on("searching", () =>
let query = this.$parent.search;
axios
.get("api/findVTI?q=" + query)
.then(data =>
this.ticketInvoices = data.data;
)
.catch();
);



I MADE A ROUTE





Route::get('findVTI', 'APITicketInvoiceController@searchVTI');




IN MY INVOICE CONTROLLER I DID THIS





 public function searchVTI()

if($search = Request::get('q'))
$VTI = TicketInvoice::where(function($query) use ($search)
$query->where('ticket_invoice_no','LIKE',"%$search%")
->orWhere('ticket_invoice_grand_total','LIKE',"%$search%")
->orWhere('vendor_company_name','LIKE',"%$search%");
)->paginate(10);
else
return TicketInvoice::paginate(10);

return $VTI;




When i write this line:
->orWhere('vendor_company_name','LIKE',"%$search%"); i got an error in console that, vendor_company_name does not exist in ticket_invoices.



I play around with many thing but didn't succeed...



Image For Better Understanding:
enter image description here







javascript laravel vue.js vuejs2 axios






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 18:57









Saif ZakirSaif Zakir

8410




8410












  • obviously the column is NOT named vendor_company_name maybe it is named related_vendor instead?

    – Nikos M.
    Nov 15 '18 at 19:32











  • @NikosM. I resolved my issue by the answer below Thanks for your support.

    – Saif Zakir
    Nov 15 '18 at 22:43

















  • obviously the column is NOT named vendor_company_name maybe it is named related_vendor instead?

    – Nikos M.
    Nov 15 '18 at 19:32











  • @NikosM. I resolved my issue by the answer below Thanks for your support.

    – Saif Zakir
    Nov 15 '18 at 22:43
















obviously the column is NOT named vendor_company_name maybe it is named related_vendor instead?

– Nikos M.
Nov 15 '18 at 19:32





obviously the column is NOT named vendor_company_name maybe it is named related_vendor instead?

– Nikos M.
Nov 15 '18 at 19:32













@NikosM. I resolved my issue by the answer below Thanks for your support.

– Saif Zakir
Nov 15 '18 at 22:43





@NikosM. I resolved my issue by the answer below Thanks for your support.

– Saif Zakir
Nov 15 '18 at 22:43












2 Answers
2






active

oldest

votes


















0














You are trying to get at a lower level, you need to look at vendor.vendor_company_name you are skipping the vendor part.



->orWhere('vendor.vendor_company_name','LIKE',"%$search%");





share|improve this answer

























  • I resolved my issue by the answer below Thanks for your support. @Linuxuser07

    – Saif Zakir
    Nov 15 '18 at 22:44


















0














It isnt working because i write orWhere('vendor_company_name','LIKE',"%$search%"), but vendor is relationship and i need to write instead last orWhere something like:





->orWhereHas('vendor', function($query) use ($search)
$query->where('vendor_company_name', 'LIKE', "%$search%");
);







share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326211%2fhow-to-search-with-vendor-name-as-well%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You are trying to get at a lower level, you need to look at vendor.vendor_company_name you are skipping the vendor part.



    ->orWhere('vendor.vendor_company_name','LIKE',"%$search%");





    share|improve this answer

























    • I resolved my issue by the answer below Thanks for your support. @Linuxuser07

      – Saif Zakir
      Nov 15 '18 at 22:44















    0














    You are trying to get at a lower level, you need to look at vendor.vendor_company_name you are skipping the vendor part.



    ->orWhere('vendor.vendor_company_name','LIKE',"%$search%");





    share|improve this answer

























    • I resolved my issue by the answer below Thanks for your support. @Linuxuser07

      – Saif Zakir
      Nov 15 '18 at 22:44













    0












    0








    0







    You are trying to get at a lower level, you need to look at vendor.vendor_company_name you are skipping the vendor part.



    ->orWhere('vendor.vendor_company_name','LIKE',"%$search%");





    share|improve this answer















    You are trying to get at a lower level, you need to look at vendor.vendor_company_name you are skipping the vendor part.



    ->orWhere('vendor.vendor_company_name','LIKE',"%$search%");






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 15 '18 at 20:27

























    answered Nov 15 '18 at 20:17









    Linuxuser07Linuxuser07

    214




    214












    • I resolved my issue by the answer below Thanks for your support. @Linuxuser07

      – Saif Zakir
      Nov 15 '18 at 22:44

















    • I resolved my issue by the answer below Thanks for your support. @Linuxuser07

      – Saif Zakir
      Nov 15 '18 at 22:44
















    I resolved my issue by the answer below Thanks for your support. @Linuxuser07

    – Saif Zakir
    Nov 15 '18 at 22:44





    I resolved my issue by the answer below Thanks for your support. @Linuxuser07

    – Saif Zakir
    Nov 15 '18 at 22:44













    0














    It isnt working because i write orWhere('vendor_company_name','LIKE',"%$search%"), but vendor is relationship and i need to write instead last orWhere something like:





    ->orWhereHas('vendor', function($query) use ($search)
    $query->where('vendor_company_name', 'LIKE', "%$search%");
    );







    share|improve this answer



























      0














      It isnt working because i write orWhere('vendor_company_name','LIKE',"%$search%"), but vendor is relationship and i need to write instead last orWhere something like:





      ->orWhereHas('vendor', function($query) use ($search)
      $query->where('vendor_company_name', 'LIKE', "%$search%");
      );







      share|improve this answer

























        0












        0








        0







        It isnt working because i write orWhere('vendor_company_name','LIKE',"%$search%"), but vendor is relationship and i need to write instead last orWhere something like:





        ->orWhereHas('vendor', function($query) use ($search)
        $query->where('vendor_company_name', 'LIKE', "%$search%");
        );







        share|improve this answer













        It isnt working because i write orWhere('vendor_company_name','LIKE',"%$search%"), but vendor is relationship and i need to write instead last orWhere something like:





        ->orWhereHas('vendor', function($query) use ($search)
        $query->where('vendor_company_name', 'LIKE', "%$search%");
        );








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 22:45









        Saif ZakirSaif Zakir

        8410




        8410



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326211%2fhow-to-search-with-vendor-name-as-well%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto