Posts

Showing posts from 2020

Laravel Validation - Unique rule with multiple column and condition.

Today I am going to share, How we can use Laravel validation rule `unique`. If you have worked with laravel and familiar with laravel validation, you must know what does 'unique' rule checks. If not let me give here a brief about this. In simple words, It is similar to a unique key constraint applied to a column in the database table. 'Unique' rule check there is no similar value exists in the given database table column, to value matching with the provided input value. The general format of the rule is: unique:table //when input name is similar to column name OR unique:table,column OR unique:Model,attribute Examples: 'email' => 'unique:users' //here users is table name OR 'email' => 'unique:c,email_address' //can give custom column name. OR 'email' => 'unique:User,email'  //here User is a model class This is a very simple usage ...

Get Free SSL Certificate from Let’s Encrypt for your website - Linux, Apache, EC2, Heroku.

Image
To enable HTTPS on your website, you need a certificate from a Certificate Authority (CA). Let’s Encrypt is a nonprofit Certificate Authority providing Free SSL certificates to 225 million websites.  You can also get a (absolutely) free SSL certificate using Certbot. Certbot is open-source software tool recommended by Let's Encrypt to for automatically deploy SSL certificate. This certificate is as valid as a paid certificate. There are two ways to get and install certificate on your server. 1. When you have SSH access to your server. Then you have option to Generate and Deploy SSL certificate automatically by installing Certbot on your server. 2. When you are using a platform like Heroku (Paas) where you don't have SSH access to your server directly and can't install any package on it. In this case you can install Certbot at your local system (Linux) using below commands and use it only to generate certificate files. Later you can Deploy them manually. Install Certbot a...

LEAST() and GREATEST() - Postgres SQL Amazing But Rarely Known Functions .

PostgresSQL is very powerful and one of the world's most advanced open-source relational databases. It gives much more flexibility and customization on query level when you want to perform a complex operation or complex queries on the database. Postgresql provides multiple operators and functions which make even complex operations and complex queries pretty easy and simple. Similarly LEAST() and GREATEST() are functions that make your work very easy and simple. LEAST() and GREATEST() functions are very useful when you want to operate on different columns within the same row (a record) in a table. LEAST() and GREATEST() compare and find the minimum and maximum value respectively among given columns values in the same row. It's similar to finding a minimum or maximum value from an array of given values. Here are a few simple examples you can try: select LEAST(5, 3, 9, 2, 8, 1) and GREATEST(5, 3, 9, 2, 8, 1); //should give 1 and 9 respectively In-case of String or Varchar, it gi...

How to Apply SSL Certificate (non-self) on EC2 with Linux/Ubuntu having Apache Server.

Assuming you are well aware of What is an SSL certificate? Why we need it? here I am going to guide you for How you can apply an SSL certificate for your website hosted on Linux or Ubuntu Server using Apache 2 server. You can either purchase a new SSL certificate or can generate it for free on  sslforfree.com  which authorized by  Letsencrypt  the first non-profit CA. After Purchasing or getting your SSL certificate you have actually 2 SSL files, Certificate and Private Key. You can upload both SSL files (certificate.crt and private.key) on the server: Create a new folder in Directory `/home/user-name/.ssh`. Create or upload files certificate (.cert) file as certificate.crt and Private key (.key) as private.key in the folder created earlier. Now edit Virtual Host configuration for the website for which you want to apply the SSL certificate. sudo nano /etc/apache2/sites-enabled/{yourwebsitedomain.com}.conf Add the following code to website vhost config...

How to Block Inspect Element and Right Click on Your Website using Simple JavaScript

Assuming you are well aware of What is an SSL certificate? Why we need it? here I am going to guide you for How you can apply an SSL certificate for your website hosted on Linux or Ubuntu Server using Apache 2 server. You can either purchase a new SSL certificate or can generate it for free on  sslforfree.com  which authorized by  Letsencrypt  the first non-profit CA. After Purchasing or getting your SSL certificate you have actually 2 SSL files, Certificate and Private Key. You can upload both SSL files (certificate.crt and private.key) on the server: Create a new folder in Directory `/home/user-name/.ssh`. Create or upload files certificate (.cert) file as certificate.crt and Private key (.key) as private.key in the folder created earlier. Now edit Virtual Host configuration for the website for which you want to apply the SSL certificate. sudo nano /etc/apache2/sites-enabled/{yourwebsitedomain....