Jump to content

Access Custom Field in Hook


Recommended Posts

Hi all, I am hoping someone can help me

 

In my hook, I can do the following to get client details and display the name of the client.

 

$client = Menu::context('client'),

$Message = <p> Hello {$client->firstName} </p>;

 

However, I want to get one of the custom client fields I have made instead. (for example VAT Number). How can I do this?

 

Thanks in advance if anyone can answer this.

Link to comment
Share on other sites

Use Capsule to grab it. Something like this


       $fieldid = Capsule::table('tblcustomfields')->where('fieldname', '=', 'VAT')->where('type', '=', 'client') ->pluck('id');
       $vatnum = Capsule::table('tblcustomfieldsvalues')->where('fieldid', '=', "$fieldid")->where('relid', '=', "$clientid")      ->pluck('value');

Link to comment
Share on other sites

Hi Twhiting,

 

I tried the following:

$fieldid = Capsule::table('tblcustomfields')->where('fieldname', '=', 'Dashboard')->where('type', '=', 'client') ->pluck('id');

$dashboardText = Capsule::table('tblcustomfieldsvalues')->where('fieldid', '=', "$fieldid")->where('relid', '=', "$clientid") ->pluck('value');

 

I seem to get a 500 error with this code. Not sure why. I checked the DB and a field with that name does exist. Any ideas?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated