Note that there are some explanatory texts on larger screens.

plurals
  1. POLaravel 4 adding custom attributes to User Model
    primarykey
    data
    text
    <p>I'm using <a href="http://packalyst.com/packages/package/spinegar/laravelsugar" rel="nofollow">this custom package</a> to integrate my SugarCRM into Laravel 4. I'm storing basic user info in my laravel database which I use to access the rest of the users data that is stored in Sugar.</p> <p>For instance, I have the company name stored into my project database. I use that to find the website, email address, etc. which is stored in Sugar. I don't want duplicate info anywhere, so I figured I would just get the other necessary Sugar user data on the fly.</p> <p><strong>The problem</strong>: I was hoping to append the Sugar data retrieved to the <code>User Model</code> but it's proving difficult and apparently that was the intention of the creator. I'm doing this in my view:</p> <pre><code>@foreach ($users AS $user) &lt;tr&gt; &lt;td&gt;&lt;a href="{{ URL::to('user/' . $user-&gt;id . '/edit') }}"&gt;{{ $user-&gt;username }}&lt;/a&gt;&lt;/td&gt; &lt;td&gt;{{ $user-&gt;main_contact_c }}&lt;/td&gt; &lt;td&gt;&lt;a href="mailto:{{ $user-&gt;email }}" target="_blank"&gt;{{ $user-&gt;email }}&lt;/a&gt;&lt;/td&gt; &lt;td&gt;{{ $user-&gt;role }}&lt;/td&gt; &lt;td&gt;[ Get From Sugar API ]&lt;/td&gt; &lt;td&gt;&lt;a data-toggle="modal" href="#confirm-user-delete"&gt;&lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt;&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; @endforeach </code></pre> <p>I know it's bad design to call model methods from a view so I'm not sure how to properly access my custom data that pertains to each record. I could create the function <code>getMainContactCAttribute()</code> in the User Model but I can't pass info to the function in the view obviously...What are some legit things I can do?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload