InfyOm Blog

latest-post

Recently, I have created a new package for Laravel Community. it's called Laravel PWA. first of all what is PWA? let me explain a bit more about PWA. PWA means progressive web application. PWA provides a facility to install your web application on mobile and desktop. you don't need to write lots of line code in native platform-specific code.

You can create a PWA site in a few minutes using Laravel PWA.

You can watch the video tutorial as well to install this package.

Step 1:

Install the package by the following command,

composer require ladumor/laravel-pwa

Step 2:

Add Service Provide into app.php config file in provider section. You can skip this step if you installed it in Laravel 6 and more.

Ladumor\LaravelPwa\PWAServiceProvider::class,

Step 3:

Add Facade to app.php config file in aliases section. You can skip this step if you installed it in Laravel 6 and more.

'LaravelPwa' => \Ladumor\LaravelPwa\LaravelPwa::class,

Step 4:

I think installation is done and no need to publish all the assets using the following command,

php artisan laravel-pwa:publish

Step 5:

This step is very important. you published all the assets in the previous step. now, you need to link all the assets in your main blade file. for ex app.blade.php

Add the following code in the root blade file in the header section.

<!-- PWA  -->
<meta name="theme-color" content="#6777ef"/>
<link rel="apple-touch-icon" href="{{ asset('logo.PNG') }}">
<link rel="manifest" href="{{ asset('/manifest.json') }}">

Add following code in root blade file before close the body,

<script src="{{ asset('/sw.js') }}"></script>
<script>
    if (!navigator.serviceWorker.controller) {
        navigator.serviceWorker.register("/sw.js").then(function (reg) {
            console.log("Service worker has been registered for scope: " + reg.scope);
        });
    }
</script>

You should watch this tutorial if you want to set it up manually instead of using this package.

October 08, 2021userShailesh Ladumor

Posts

post

Nowadays, people are hacking secure data systems, so will See the security testing criteria for reCAPTCHA forms.

reCAPTCHA is a technology that assesses the probability that the entity that uses your web code (page, app, portal, etc.) is a human and not a bot (or the other way around). Grabbing information of behavior (of a user or a bot) encapsulates it in the token that gets sent to your server. On your server, the token is being sent again to Google for returning the assessment on how probable it is that the token was generated by a human. Part of the response returned from Google to your server:

Let's See the points how to Test 🛠️

First, we validate from the frontend

on any reCAPTCHA from removing that div from inspect element and then trying to save there must be valid and records should not store on the backend as shown in the image.

2021-07-22-60f90c027ead1

Remove this div then save the form there should be a validation message for reCAPTCHA verification and the form should not be saved, if the form is submitted then the data were stored in the data table which was False to the system.

Now Let's see how we validate from the postman

First, add testing form URL on browser and apply Post method and on body add all fields which are added in form lets see on the image.

2021-07-22-60f90c12e0f33

Now add on the header at Key column CSRF token, X-Requested, cookie and add its perspective value as shown in the image.

CSRF token and XSRF-TOKEN will store in the cookie which will get from the front page from inspect element.

2021-07-22-60f90c2315082

Now, click on send request and validate the status should be false as shown in the image

2021-07-22-60f90c3081ca1

If the status changes to true, then the data stored in a table & will create a problem, and the reCAPTCHA form will validate false.

Hence, reCAPTCHA form Test, Hope this helps.

July 24, 20213 minutesauthorShailesh Ladumor
post

But if you want to add another project as a library in your application. For that, you need to add that library project to your application as a module dependency.

1. Open Your Project in Android Studio.

2. You will find the two main directory name samples and others.

3. Go to Android Studio and navigate to File -> New -> Import Module -> Select the library path -> Finish.

2021-07-24-60fbb0d6a0a7c

4. Import-Module from Directory.

2021-07-24-60fbb6e95102d

5. Then right-click on the App directory -> Open Module Settings -> Dependencies -> Click on + button inside Declared Dependencies -> Module Dependency -> Select your library -> Ok.

2021-07-24-60fbb90b68dec

2021-07-24-60fbb99dd54e3

Another way to add Module Dependency

  • Open build.gradle Of the main module
dependencies {

implementation project(":sample")

}

There can be a situation when we need to modify the library code according to our requirement then in that case we can follow this method.

July 25, 20212 minutesauthorVivek Beladiya
post

One of my tasks today was to create a banner and I thought to myself which software should I choose Adobe Photoshop or Illustrator and yes it is obvious that I have chosen Adobe Illustrator and later I decided to write you an article saying that you need Adobe Illustrator To convince you about why you should learn. You are a graphic designer or web developer.

The Big Muscles to Adobe Illustrator

You may think that learning Adobe Illustrator in 2021 is pointless since most of the work can be done on Adobe Photoshop, and with the release of Adobe XD there can be all layouts and planning. What does it mean after all? Well here are some of the things Adobe Illustrator does best but first

What is Adobe Illustrator?

Adobe Illustrator is a software developed and published by Adobe Inc. since 1987. At first, it was only available for Mac but in later years it was also available for Windows. It is used to create vector scalable graphics.

What is Vector Graphic you ask?

There are two types of 2D graphic vector and raster.

Raster Graphics

Raster graphics are made up of a grid of pixels, each of which can have a different color. The main drawback of this is that it can only be made smaller (the size can be reduced) but if you try to increase the pixels the image will become blurred. Ex: Digital photographs, icons, etc.

Adobe Photoshop is a raster graphic software used for editing these types of images.

Vector Graphic

Vector graphics are made in a simple way that can create shapes, letters, or any other line objects. They follow mathematical formulas that provide information about these lines, such as colors, and what shapes to form. This type of graphics can be measured infinitely and it will never lose design.

Now since that’s out of the way let’s get back to our main topic

Best for designing Logo

It is always better to design the locator in vector format so that you can resize any color as you like. Customers always zoom in, check out the detailed view of the logo, the vector graphic is easy to customize.

Exported to SVG

One of the best things about Adobe Illustrator is that it can be exported directly in the form of SVG so you don't have to worry about the best resolutions for websites.

Web Designing

Adobe Illustrator is really the best way to create wireframes (the basic structure of a website or application) and lay it out and has many built-in features to do so.

Create your custom font, cartoons, and artworks

Ever seen stylish-looking text or artwork on Instagram or any social media platform and wonder if I want to create something like that, but don’t know how? Here's your

answer: Learn Adobe Illustrator and you will be able to do it with practice.

How to make the font

  • Sketching: Sketch the letters by hand.
  • Tracing: Use the scanner to get that image into the system and open that image in Illustrator. Now trace the letters with the pen tool.
  • Reorganizing: Accurate, readability and Corning images you are looking at are refined and organized.
  • Saving: Save the glyph and export it using additional plug-ins.
  • Using: Put that new brand into your new design for good use.

Patterns with just a few repeats

Illustrator is the ACR of creating peters with repeat options. You repeat, reflect, and ask for spas between objects and your pattern is ready.

The Infographic

Infographics are a very popular way to illustrate a topic with shapes, budgets, some data, and text. Creating charts in Adobe Illustrator is easy, just need to enter and complete some values. Infographics can be easily designed in Illustrator. This infographic is also saved in EPS format which is best for printing.

Easy to Learn

Trying to learn Adobe Photoshop, your first week will be literally the hardest learning of all those shortcuts while learning Adobe Illustrator is fairly easy. No need to create new layers every time, in Adobe Illustrator you just do your work because you like that the whole screen is your work area (inside or outside the artwork).

In other words, what I'm trying to say is that Adobe Illustrator is software that can be used in most scenarios and gives you the freedom to express your creativity without having to wonder how color can fill in the blanks.

July 27, 20214 minutesauthorKishan Savaliya
post

Hi everyone, in this post, we will discuss Room Database in android java.

Below are all steps covered in this blog

  • How to use the Room database
  • How to add Room Database in android studio
  • Insert,Update,Delete record
  • How to pass query in Database

What is a Room?

  • The Room strong library provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite.

  • Normally Room databases are fast created and have good performance like reading, updating and deleting records. Room Database makes everything easy and fast

  • Room Database more detail open this link: https://developer.android.com/training/data-storage/room/

Components of Room Here room have main 3 components

Entity:

  • Instead of creating the SQLite table, we will create the Entity. An entity is nothing but a model class annotated with @Entity. The variables of this class are our columns, and the class is our table.

Database:

  • It is an abstract class where we define all our entities.

DAO:

  • Stands for Data Access Objects. It is an interface that defines all the operations that we need to perform in our database.

Demo App Create

  • First, we create a new project in android studio.
  • Name of my project "Room DataBase"

Adding Dependencies

  • Add needed dependencies for the room database.
  • Android studio in this file add dependencies "build.gradle".
  • See the below image and add the latest version room database replace here "$room_version" add original version

First, we will create DAO class:

  • This DAO class-main work intermediary between the user and database. All performed operations are defined here.
  • Below create StudentDao class
@Dao
public interface StudentDao {

@Query("SELECT * FROM Student")
List<Student> getAll();

@Insert
void insert(Student student);

@Update
void updateTask(Student student);

@Delete
void deleteTask(Student student);
}

Nowhere explain all components of StudentDao Class

  • Compulsory add class upper "@Dao" keyword
  • Three methods create insert, update, delete
  • Most important thing here is "@Query"

What is a Query?

  • Using query to get database existing record.
  • @Query("SELECT * FROM Student") this query gets all student records.
  • But the user wants to get only the standard "5" student record and only get how to pass a query?
    @Query("SELECT * FROM STUDENT where std = :std")

    List<Student> dataCheck(String std);
  • Here "std" id table field name
  • Call this method "data check(String std)" pass a string in "5" and database in getting only 5 stander student record
  • So this concept use the query parameter

Second steps create student model class

@Entity(tableName = "student")
public class Student implements Serializable {

@PrimaryKey(autoGenerate  = true)
private int id;

@ColumnInfo(name = "std")
private int std;

@ColumnInfo(name = "name")
private String name;

public int getId() {
    return id;
  }

public void setId(int id) {
    this.id = id;
  }

public int getStd() {
    return std;
  }

public void setStd(int std) {
    this.std = std;
  }

public String getName() {
    return name;
  }

public void setName(String name) {
    this.name = name;
  }
}
  • PrimaryKey: auto increment values
  • tableName : user wants to set the table name
  • ColumnInfo: give the table in columns name

Third steps Create Database class:

@Database(entities = {Student.class}, version = 1)
public abstract class AppDatabase extends     RoomDatabase {
public abstract Student studentDao();
}
  • User wants to add multiple tables how can add like that:

@Database(entities = {Student.class,Abc.class,Xyz.class}, version = 1) public abstract class AppDatabase extends RoomDatabase { public abstract Student studentDao(); }

  • To create a new model class like Abc.class and Xyz.class etc same method.

Fourth step inserts, update and delete records create separate method:

 public class InsertUpdateDeletRecord {

    private String DB_NAME = "db_task";

    private Student Student;
    public studentRepository(Context context) {
        Student = Room.databaseBuilder(context, Student.class, DB_NAME).build();
    }

    public void insertTask(String std,String name) {

        insertTask(std, name);
    }

    public void insertTask(String std,String name) {
        Student student = new Student();
        student.setstd(std);
        student.setname(name);

        insertTask(student);
    }

    public void insertTask(final Student student) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... voids) {
                Student.daoAccess().insertTask(student);
                return null;
            }
        }.execute();
    }

    public void updateTask(final Student student) {
        student.setModifiedAt(AppUtils.getCurrentDateTime());

        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... voids) {
                Student.daoAccess().updateTask(student);
                return null;
            }
        }.execute();
    }

    public void deleteTask(final int id) {
        final LiveData<student> task = getTask(id);
        if(task != null) {
            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... voids) {
                    Student.daoAccess().deleteTask(task.getValue());
                    return null;
                }
            }.execute();
        }
    }

    public void deleteTask(final student student) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... voids) {
                Student.daoAccess().deleteTask(student);
                return null;
            }
        }.execute();
    }

 }

Sample Implementation of basic CRUD operations using ROOM

Insert:

 InsertUpdateDeletRecord 
 insertUpdateDeletRecord = new 
 InsertUpdateDeletRecord(getApplicationContext( ));
 String std = "5";
 String name = Android";
 insertUpdateDeletRecord.insertTask(title, 
 description);

Update:

 InsertUpdateDeletRecord 
 insertUpdateDeletRecord = new 
 InsertUpdateDeletRecord(getApplicationContext( ));
 Student student = 
 insertUpdateDeletRecord.getTask(2);
 student.setName("Java");
 student.setStd("6");
 insertUpdateDeletRecord.updateTask(student);

Update:

 InsertUpdateDeletRecord 
 insertUpdateDeletRecord = new 
 InsertUpdateDeletRecord(getApplicationContext());
 insertUpdateDeletRecord.deleteTask(3);
July 25, 20214 minutesauthorPankaj Valani
post

Nowadays, people are hacking secure data systems, so will See the security testing criteria for reCAPTCHA forms.

reCAPTCHA is a technology that assesses the probability that the entity that uses your web code (page, app, portal, etc.) is a human and not a bot (or the other way around). Grabbing information of behavior (of a user or a bot) encapsulates it in the token that gets sent to your server. On your server, the token is being sent again to Google for returning the assessment on how probable it is that the token was generated by a human. Part of the response returned from Google to your server:

Let's See the points how to Test 🛠️

First, we validate from the frontend

On any reCAPTCHA from removing that div from inspect element and then trying to save, there must be valid and records should not store on the backend as shown in the image.

2021-07-22-60f90c027ead1

Remove this div then save the form there should be a validation message for reCAPTCHA verification and the form should not be saved, if the form is submitted then the data were stored in the data table which was False to the system.

Now Let's see how we validate from the postman

First, add testing form URL on browser and apply Post method and on body add all fields which are added in form lets see on the image.

2021-07-22-60f90c12e0f33

Now add on the header at Key column CSRF token, X-Requested, cookie and add its perspective value as shown in the image.

CSRF token and XSRF-TOKEN will store in the cookie which will get from the front page from inspect element.

2021-07-22-60f90c2315082

Now, click on send request and validate the status should be false as shown in the image

2021-07-22-60f90c3081ca1

If the status changes to true, then the data stored in a table & will create a problem, and the reCAPTCHA form will validate false.

Hence, reCAPTCHA form Test, Hope this helps.

July 22, 20214 minutesauthorBhumi Khimani
post

Last week, we run into a problem for one of the large Gatsby + ReactJS + Laravel projects in hosting which is hosted with Apache Webserver on Amazon AWS EC2. The problem we were facing was, for some reason, when we reload the Gatsby website, it was giving a 404 error page.

If you open a home page and then a normal visit then the website will fully function, but if you reload the page then it gives an error. And we found it happens when we are using Dynamic routing of React Route in Gatsby as per show in Gatsby documentation here.

Also, what we found, if we test the website build with gatsby serve then it works fine. But while using Apache, it behaves differently and we found that this problem has been faced by lots of people over the internet.

So what we came up with is, we used gatsby serve with an apache proxy. Here is how we did it,

Step 1 - Setup Project

As a first step, clone the project on the server and run a command, gatsby build to create a gatsby build.

Step 2 - Setup PM2 for Gatsby Serve

The next step that we need to do is run gatsby serve. But as you know, we can not run this command directly via console, because as you exit from the console, the command will be terminated.

So we will be using pm2 package, a NodeJS utility that is used to run nodejs apps.

For that, we will need to install pm2 globally. Run the following command to install it,

npm install pm2 -g

You can find other installation ways here if you need.

Once the installation has been done, let's run the gatsby serve command via pm2. For that run the following command from the gatsby project folder,

pm2 start gatsby --name my-web-app -- serve

where my-web-app you can replace with the name of your app.

Once, it's running, try to test it, if it's working correctly by opening the URL http://your-ip-address:9000/. Make sure, port 9000 is opened on your server for traffic.

Step 3 - Configure Apache

Once, gatsby serve is working and tested. The next step is to configure apache to proxy all port 80 traffic to port 9000.

For that, edit your apache conf file (or virtual host conf file), and add the following lines (or configure it to something like the following),

<VirtualHost *:80>
        ServerName my-web-app.infyom.com

        ServerAdmin webmaster@infyom.com

        ProxyRequests On
        ProxyPass / http://localhost:9000/
        ProxyPassReverse / http://localhost:9000/

        ErrorLog ${APACHE_LOG_DIR}/my-web-app.infyom.com.error.log
        CustomLog ${APACHE_LOG_DIR}/my-web-app.log combined

        ......
        # any other options below as per your need
        ......
</VirtualHost>

The next step you need to do is restart your apache server by,

sudo service apache2 restart

And then you can just open the URL https://my-web-app.infyom.com and it should work fine.

Bonus

New Deployment

Whenever you deploy a new code, you again need to run gatsby build and then pm2 restart my-web-app. Then only it will take new changes.

Troubleshooting

Sometimes, we found that we need to restart apache as well after the new deployment. so if you run into any trouble, then make sure to restart apache as well and it should solve the problem.

I hope it may help you to resolve your 404 problem.

July 16, 20213 minutesauthorMitul Golakiya
post

Generally, we are using a Laravel One Signal package for push notification. if you are planning to use one signal in the mobile application then this package right for you.

Recently, I add a new feature UserDevice. let me explain why I added support for user Device APIs.

We need to create an API to register a device because One Signal sends a push notification using os player id. so, we need to store os_player_id in the backend from the mobile application. So, need to create an API for it.

Now. you can save your time using this package. you can Generate APIs using one artisan command,

php artisan one-signal.userDevice:publish

This command generates the following files,

  • UserDeviceAPIController
  • UserDeviceAPIRepository
  • UserDevice (model)
  • Migration So, everything is ready in minutes and delivered an API on the spot.

Also, do not forget to add the following routes to the api.php file.

use App\Http\Controllers\API\UserDeviceAPIController;

Route::post('user-device/register', [UserDeviceAPIController::class, 'registerDevice']);
Route::get('user-device/{playerId}/update-status', [UserDeviceAPIController::class, 'updateNotificationStatus']);

If you are a good Eye listener then you should watch the video tutorial

July 08, 20211 minuteauthorShailesh Ladumor
post

People nowadays are becoming more intelligent, so better to protect our application's content/data from those who are calling themself hackers.

One of the best examples is the data URLs from AWS buckets. it's not a good idea to store sensitive data into a public AWS Bucket, as the URL is accessible by the people.

Of Course, you can store profile avatars and others data to the public bucket's that not contains any confidential information. so that's fine.

But when it's about confidential information like PAN CARD Details, AADHAR Card Details, Bank Informations we Must Recommend using AWS Protected Bucket.

In this tutorial, we are going to show that how we can prevent that kind of case, Or how we can integrate AWS Protected Bucket in our Laravel Application.

The following code will help you to generate a pre-signed AWS URL that will prevent our data, that URL is non-guessable and it will expire within some minutes/hours specified by us.

So let's start with some code :

$s3 = \Storage::disk(config('filesystems.s3_protected_disk'));
$client = $s3->getDriver()->getAdapter()->getClient();
$expiry = "+1 minutes";
$command = $client->getCommand('GetObject', [
  'Bucket' => \Config::get('filesystems.disks. s3_protected_disk.bucket'),
      'Key'    => 'Path to your file',
    ]);
$request = $client->createPresignedRequest($command, $expiry);
    return (string) $request->getUrl();

So here we have created an s3 instance and it's stored on the $s3 variable, we have specified the expiry time as 1 minute so the given URL for data will be expired within a minute.

Also, we have to specify the bucket name and path to our protected file to generate AWS pre-signed URL.

It will return the pre-signed URL and its looks like as the following URL.

https://pre-signed.s3.au-west-2.amazonaws.com/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxxxx%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20210210T171315Z&X-Amz-Expires=60&X-Amz-Signature=xxxxxxxx&X-Amz-SignedHeaders=host

Hope this helps.

July 16, 20212 minutesauthorVishal Ribdiya