Posts

Using Virtual Columns in Laravel - Accessors and Appends

What are virtual columns?  While developing any web application sometimes we need virtual columns - columns don't actually exist in our DB table, but we drive them from other columns. Why we need them? For example, generally, we use first_name and last_name  in the  users table. But sometimes we also need user's complete name i.e. full_name . There is no benefit of saving full_name in user table if we have already first_name and last_name in the table OR even if we have full_name  as a column in our table then there is no benefit of saving first_name and last_name in the table. So in a scenario like this, we prefer to use the virtual column. Using Virtual Columns in Laravel Considering the first case, in Laravel to get virtual column i.e.  full_name  from the users table will have Accessors. Accessors are methods defined automatically called by Eloquent when select is called on that particular column. Let take an example here: To get full_...

Laravel validation rule 'Exists' with secret feature.

In this post, I wish to share one secret feature of laravel validation rule 'Exists'. If you have worked with laravel and familiar with laravel validation, you must know what does 'Exists' rule checks. If not let me give here a brief about this. In simple words,  'Exists' rule check if a record exists in the given database table with column value matching with the provided input value. Format: 'exists:table,column' So this is what as mentioned in laravel documentation too. So looking at the format we understand that this rule is to validate given input value by check if any records exist or not for that particular input value matching with the given column values of the table. Let's take an example. 'booking_id' => 'exists:bookings,id' Here we are validating provided booking_id with exists, if records exist in bookings table matching the column id (in most of the cases but can use any column as per your requirement.) ...

What is an icalender or .ics file?

Image
An icalender or ics file is a simple text file with some pre-defined format and tags saved with extension .ics. It is usually used for inviting someone to an event via email to which user can respond to actual sender very easily or can add an event in his/her calendar i.e. Google Calendar, Apple Calendar etc. The file format is specified in a proposed internet standard RFC 5545  . A Simple Example ICS file ICS file has a pre-defined format and Tags like if we talk about HTML page. BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN CALSCALE:GREGORIAN METHOD:REQUEST BEGIN:VEVENT DESCRIPTION:Meeting of board members DTSTART:20190206T090828Z DTEND:20190206T093828Z SUMMARY:Meeting LOCATION:6116 Breitenberg Radial Vanessaview\, AK 79372-4114\, West Vincenzo\, 86360-8926 URL:http://example.com DTSTAMP:20190206T090828Z UID:5c5aa40c3f305 ORGANIZER;CN=Joelle:MAILTO:ohackett@example.org END:VEVENT END:VCALENDAR ...

This is my First Post.

Today i am starting to write this blog to share my personal experience, knowledge or skills i learned in the life.