<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sydney Abuya</title>
    <description>The latest articles on DEV Community by Sydney Abuya (@sydney_abuya_87).</description>
    <link>https://dev.to/sydney_abuya_87</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1640313%2F1be215a3-54e1-4595-a116-66b10a7333d1.png</url>
      <title>DEV Community: Sydney Abuya</title>
      <link>https://dev.to/sydney_abuya_87</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sydney_abuya_87"/>
    <language>en</language>
    <item>
      <title>Laravel Attributes</title>
      <dc:creator>Sydney Abuya</dc:creator>
      <pubDate>Sun, 19 Jan 2025 19:26:42 +0000</pubDate>
      <link>https://dev.to/sydney_abuya_87/laravel-attributes-oei</link>
      <guid>https://dev.to/sydney_abuya_87/laravel-attributes-oei</guid>
      <description>&lt;p&gt;If you want to use the profile_image attribute from an accessor method in your Laravel Eloquent model and have it return /user.png as a fallback when the attribute is empty or false, you can define the accessor within your model. Here's how you can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User extends Authenticatable
{
    // Other model code...

    public function getProfileImageAttribute($value)
    {
        return $value ? asset('/storage' . $value) : url('/user.png');
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this accessor defined in your User model, whenever you access the profile_image attribute of a User model instance, it will go through this accessor method. If the value is not empty ($value evaluates to true), it will return the asset URL based on the value. Otherwise, it will return the fallback URL /user.png.&lt;/p&gt;

&lt;p&gt;In your Blade template, you can then directly use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;auth()-&amp;gt;user()-&amp;gt;profile_image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;without any additional logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src="{{ auth()-&amp;gt;user()-&amp;gt;profile_image }}" alt="User Image"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why is it named like this getProfileImageAttribute($value)&lt;br&gt;
In Laravel’s Eloquent ORM, attribute accessors are defined using a naming convention that consists of three parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;get:&lt;/strong&gt; This indicates that the method is a getter accessor. It's used when you retrieve the value of the attribute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AttributeName:&lt;/strong&gt; This part represents the name of the attribute you want to define an accessor for. In your case, it's ProfileImage. The name of the attribute is typically written in "studly case", which means each word in the name starts with an uppercase letter and there are no spaces or underscores between words.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attribute:&lt;/strong&gt; This part indicates that the method is an attribute accessor.
So, when you put them together, &lt;code&gt;getProfileImageAttribute($value)&lt;/code&gt; means:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;get: It's a getter accessor.&lt;/li&gt;
&lt;li&gt;ProfileImage: It's for the profile_image attribute.&lt;/li&gt;
&lt;li&gt;Attribute: It's an attribute accessor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This naming convention is used to automatically map attribute accessors to the corresponding attributes in the Eloquent model. When you retrieve the value of the profile_image attribute using $model-&amp;gt;profile_image, Laravel internally looks for an accessor method named getProfileImageAttribute to provide the value of the attribute. This convention helps Laravel automatically invoke the accessor method when needed without any additional configuration&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>php</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>SQL Oracle</title>
      <dc:creator>Sydney Abuya</dc:creator>
      <pubDate>Sun, 07 Jul 2024 09:08:24 +0000</pubDate>
      <link>https://dev.to/sydney_abuya_87/sql-oracle-169p</link>
      <guid>https://dev.to/sydney_abuya_87/sql-oracle-169p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Use of distint&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before the 1st column name&lt;/li&gt;
&lt;li&gt;avoids duplicate data in column&lt;/li&gt;
&lt;li&gt;can not be used twice on one table&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use of q and [], ()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;words in side having&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Select from dual;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an unexisting table that can be used&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Column aliases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;eg select first_name name;&lt;/li&gt;
&lt;li&gt;select first_name as name;&lt;/li&gt;
&lt;li&gt;select first_name AS name;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Concatenation using ||&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;select first_name || ' ' || last_name as "full name"&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Life as a software developer</title>
      <dc:creator>Sydney Abuya</dc:creator>
      <pubDate>Sun, 07 Jul 2024 08:23:05 +0000</pubDate>
      <link>https://dev.to/sydney_abuya_87/life-as-a-software-developer-5d7a</link>
      <guid>https://dev.to/sydney_abuya_87/life-as-a-software-developer-5d7a</guid>
      <description>&lt;p&gt;&lt;strong&gt;Satisfaction in Building&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product coming to life&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Teamwork&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mentor and learn from the rest&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Evolving&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Taking up new challenges &lt;/li&gt;
&lt;li&gt;Thinking outside the box&lt;/li&gt;
&lt;li&gt;Involves : creating new features, optimization of code, critical debugging&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What makes a good developer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Handling&lt;/strong&gt; : What if this happens&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling to empty/null value&lt;/strong&gt;: This is having the capability of returning a valid message for the user whenever nothing is found form your query.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Levels as a Software Developer
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Needs improvement&lt;/li&gt;
&lt;li&gt;Consistently meeting expectation&lt;/li&gt;
&lt;li&gt;Exceeds expectations&lt;/li&gt;
&lt;li&gt;Strongly Exceeds&lt;/li&gt;
&lt;li&gt;Superb&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Where do you fall?&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>laravel</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
