InfyOm Blog

latest-post

In our daily life, we are going through lots of packages, and some of us don't know how to build our own package into Laravel.

We are going to perform the core steps to create your own package in laravel. In this tutorial we are going to build zoom package, so we will perform steps related to it.

Setup Fresh Laravel Repo 

Setup fresh laravel repo, and then create directories within it. 

for e.g Create infyomlabs/zoom-api directory into root.


Now create src directory into zoom-api

Run Composer init Into src Directory

After hitting composer init it will ask some information from you, as you can see in below image I have entered some of information. you can just hit enter if you do not want to add other information.


Add your config file (Optional)

Create directory config into src directory and add your config.php file there from where you can manage your env variables. 


Add Service Provider

Create your service provider from where you can do lots of actions. like you can publish config/routes/ migrations files from there. here we are publishing the zoom config file. 


Add your class (Which contains all functions) 

Here we have added a Zoom class which will be contained all zoom functions. 

Update Composer.json 


Finally, Test it in your existing project

Put the following code to your main composer.json (in your project's root). and hit composer update

  "repositories": [
        {
            "type": "path",
            "url": "infyomlabs/zoom-api",
            "options": {
                "symlink": true
            }
        }
    ],
    "license": "MIT",
    "require": {
        "infyomlabs/zoom-api": "dev-develop"
    },


January 27, 20211 minuteuserVishal Ribdiya

Posts

post

Recently, we have started working on one CRM System for client, where we offer a user to create an account and then can upload his excel file of Contracts and we will create contracts in the database, and then these contracts will be emailed to both the parties of the contract.

For this, the functionality we want is, we do not let users wait to do these all things, because this process may take longer based on the number of records the user has. Also, this process contains lots of computation like,

  1. Upload an Excel file
  2. Do field mappings
  3. Validate the record of contract
  4. Create a contract in the database along with all other information
  5. Create a PDF of contract (which take significant time)
  6. Email that PDF to both the parties.

Just imagine, if the user has uploaded a file with 10K records in a file it will take an hour to do this in a single process.

Here is where we used the Laravel Jobs & Queues where we can let use relax and we do our processing in backend with multiple Jobs running at the same time.

So we came up with architecture with Several Jobs in place with the following things in mind.

  1. We will have multiple Jobs to perform multiple things to have SRP (Single Responsibility Principle)
  2. When the one Job completes its duty, it will dispatch the next Job with the data that next job needs.
  3. The next job will do that same till the process ends

Another advantage we got here is, we can execute different jobs on different machines/servers based on the resources required. For e.g. We run a Job of Creating PDF on a powerful machine then sending an email.

Also, we can set different priorities for different Job Listeners. For e.g. Sending an Email Job will have a lower priority than others.

So here is the architecture that we came up with and used. I tried to architect the Jobs structure only and haven't mentioned small details of updating and creating records.

Implementing Efficient and Fast Data Import with Laravel Jobs & Queues

Hope it will help you to architect you a better Jobs and Queues architecture where you need to perform multiple things on the backend and do not let your users wait to finish those long-running processes.

Happy & Safe Queuing. :)

August 14, 20202 minutesauthorMitul Golakiya
post

Step:1 Create a new artboard

Create new art board fill property width 1920 hight 1080 resolution 75px/inch color mode RGb-8bit background white.

Step:2 Select Add a layer style

Click the lock icon to unlock the background and double click it to open click gradient overlay and the gradient bar.

Click the black & white thumbnail in the lower-left step click the color box and pick a soft color that works with your subject.

Step:3 Set Image In artboard

Press v on your keyboard drag the photo onto the keyboard to reposition it just drag it.



Once you're happy with its size and position press enter or return next we'll septate the subject from its background by making a selection around the subject. there are many ways to do this but for this example, I'll use the quick selection tool if you're using

Step:4 Crop as a requirement

This tool as well makes it's radius anywhere between 5 and 10 pixels drag the tool over the inside of your subjective selection



Step:5 Select Refine edge

Those areas to refine the selection edge click refine the edge and check smart radius this detects smooth and hard edge drags the radius a little bit to the right to adjust the size of your project make sure.

The caps lock key is off and press the right or left bracket key on your keyboard drag the brush cover all soft edges like air and press OK.



Step:6 Add Drip image

How to hook it to a new layer with a layer mask open the background.

Ctrl-click the dripping photo to make a selection make the original subject photoactive and press the delete icon on your keyboard click eye ball to hide the dripping pattern then be selected by pressing Ctrl+D.



Step:7 Add Brush Style

Click the new layer icon to make a new layer drag it below your subject.



Set open brush tool and brush picker take this flat seven board number 504 for brush download the splatter brush.



Step:8 Add Effect as per your Requirement

Make the subject layer active and open layer style window click drop shadow the blend mode is linear burn the color is black and the opacity is 100% the angle is 90 degrees and check the use global light.

The distance is 5 pixels the spread is 0% and the size is 0 pixels the contour is linear and the subject is ready



August 11, 20202 minutesauthorKishan Savaliya
post
Laravel Livewire is used to build dynamic web pages that work without ajax or any javascript code. we can build dynamic components with livewire with less code and more functionalities.

I hope this basic introduction will be enough to start laravel livewire.

Now let's move to installation steps, and I hope you already have setup your laravel project.

Install Livewire

 composer require livewire/livewire

Include the javascript and styles (On your master blade file)

  ...
     @livewireStyles
  </head>
  <body>
  ...

     @livewireScripts
  </body>
  </html>

Create Your Component

Here we are going to create a component to create a summation of 2 values without hitting any buttons, it will do a summation of 2 values as you type in text boxes.

Now let's create our component by hitting the following command :

php artisan make:livewire Summation

it will create 2 files as shown below:

// app/Http/Livewire/Summation/php
namespace App\Http\Livewire;

use Livewire\Component;

class Summation extends Component
{
    public function render()
    {
        return view('livewire.summation');
    } 
}

// resources/views/livewire/summation.blade.php
<div>
    ...
</div>

Include the component

Include created component to your view where you want to show.

 <head>
    ...
    @livewireStyles
 </head>
 <body>
    <livewire:summation />

    ...

    @livewireScripts
 </body>
 </html>

Now let's first do a change in our livewire component Summation.php

namespace App\Http\Livewire;

use Livewire\Component;

class Summation extends Component
{ 
   public $value1 = 0;
   public $value2 = 0;
   public $sum = 0;

   public function mount()
   {
      $this->sum = 0;
   }

   public function render()
   {
      $this->sum = $this->value1 + $this->value2;

      return view('livewire.summation');
   }
 }

Here we have to take 2 public properties value1, value2 and sum. and in mount method (which will be called when the page is load the first time) I have replaced the sum property value to 0.

And In the render method, I have done a summation of the 2 public property values. which will be directly accessed values of input from blade files directly here. but how ?? we will see soon.

Now let's change the livewire blade component.

  <div>
   <input type="text" class="" wire:model="value1">

    <input type="text" class="" wire:model="value2">

    <input type="text" disabled wire:model="sum">
  </div>

Here we have bind all properties by using wire:model. so as we will type in input box 1 it will be directly accessed by $value1 into the component.

and the property $sum will be changed as we change the input box values.

So that's how cool livewire is. you can create different dynamic components as you need by using livewire.

Stay tuned to read more interesting posts of a livewire.

August 07, 20202 minutesauthorVishal Ribdiya
post

Here is part one of How to Keep Your Customers Happy & Increase Repeat Project

9. Know your products and services

Customers want to work with knowledgeable employees. Learn all you can about your products so you can be better equipped to answer customer questions. If you are unsure about something, ask for help.

10. Treat your customers individually

Not all customers are the same. Every customer has individual needs and concerns and they want to be treated with a personal touch that doesn’t make them feel like a number. Communicate the way your customers want to communicate.

11. Make it easy for your customers to complain

Your customers seem to have heard, especially when they are frustrated with the service they have received. Customers know what they like and at least about your service. Ongoing surveys are a reliable and consistent approach to getting feedback but don’t miss the opportunity when you’re with a customer. Just asking you sends a beautiful message about how you value your customers and their feedback.

12. Thank your customers for every opportunity you get

Thank you very much for your customers. Thank you for calling, bringing payment, meeting you at their home, calling for help, and yes, calling for a complaint! For many, there are options available and they chose your company over the competition.

13. Never accept your customers

Your customers are your business!

14. To be active

Don't wait for your client to reach you. Reach out to them in more than one way. Improving the first call resolution cases of the customer problem will improve the overall customer experience. Create a complete self-help interface, in which customers can solve their problems manually.

15. I will take responsibility

Tell your customer that you understand that you have a responsibility to ensure a satisfactory outcome of the transaction. Assure the customer that you know what she expects and will deliver the product or service at the agreed price. There will be no unexpected charges or costs to solve the problem.

August 03, 20202 minutesauthorAnkit Kalathiya
post

While hosting on the Laravel project on cPanel, the traditional problem that lots of developers get is, /public path is appended to the URL. Because in most cases, we put a project directly into the public_html folder, so public_html is our root for the website and that's where our laravel application is also placed.

But to run the Laravel application, we need to point our domain root to the public folder of the laravel. It is possible to do with cPanel but you need to go through some steps which are not known by most of the people and also the tedious process. So to make it simple, what you can do is, there is a way we can do it via .htaccess file in our root folder.

We can copy .htaccess file from our public folder and then make modifications to it to work with the direct root folder and route every request to the public folder.

Here is the final .htaccess file,

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization MemberHeader
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Remove public URL from the path
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L,QSA]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

By adding the above file to the root folder we can use laravel project without the public path. Check out the following two lines:

  RewriteCond %{REQUEST_URI} !^/public/
  RewriteRule ^(.*)$ /public/$1 [L,QSA]

These two lines make magic and our application will work without public path in URL.

August 01, 20201 minuteauthorMitul Golakiya
post

Organisational Culture is an aspect that impacts every organization’s functioning. Keeping in view the vital role that plays in the success of any Organisation. I would like to mention the desired culture is the “OCTAPACE” Culture.

“OCTAPACE” culture is the best initiative for any Organisation, whether it’s an IT or Non-IT organization.

Let’s look at- what is “OCTAPACE” culture? How will it be helpful to Organisational Growth?

OCTAPACE Meaning Outcome
O - Openness
  • Freedom to communicate.
  • It signifies the transparency of the environment in the organization.
  • It helps to improve the implementation of any system & bring innovation by free interaction among team members, clarity in setting objects, and common Goals.
C - Confrontation
  • Facing problems and challenges.
  • The person is facing it boldly and not shying.
  • Improve Problem Solving.
  • Clarity in work.
  • Group discussion to resolve particular problems.
T - Trust
  • Maintaining confidentiality.
  • Building trust in each other.
  • Do not share anything to others or outside of the organization.
  • Higher Empathy.
  • Timely Support.
  • Reduce Stress.
A - Authenticity
  • No or narrowest gap between said value & Actual behaviour.
  • Person’s commitment to work/Assigned tasks & Actual performance should be the same.
  • Everyone has attitude “Jo me bolta hu wo me karta hu”
  • Develop mutuality culture.
  • Sharing of feeling freely.
  • Improve interpersonal communication.
  • Reduce the distortion in Communication.
P- Pro-Active
  • Taking Initiative.
  • Pre- Planning.
  • It prepared everyone for upcoming challenges.
  • Reduce uncertainty.
  • One step ahead (advance team)
  • Prepare everyone to accept changes with time.
A- Autonomy
  • Freedom to plan & act at one’s own level.
  • Organisation must avoid an Autocratic type of environment and give chance to all members to use their power in a positive way.
  • Develop mutual relationship.
  • Feeling of Pride.
  • Self Motivation
  • work satisfaction.
C- Collaboration
  • Involves working together for common cause.
  • individuales share their concerns and prepare strategies for working out plans, actions & implementing them together.
  • Timely work.
  • Resource sharing.
  • Improve Communication.
E-Experimentation
  • Trying out new ways to deal with problems/Tasks.
  • Organisation should allow all to experiment new ways and encourage them to find the best ways.
  • Accurate problem solutions.
  • Development of new products.
  • Development of New methods.


To recapitulate, Organisational culture represents Values, Beliefs, behaviors & Capabilities acquired by the members of the firm. We can truly say if the Organisation has all Dimensions of “OCTAPACE”, it is on the way to SUCCESS……….

July 31, 20202 MinutesauthorMariyam Bemat
post

Recently we use Spatie laravel-multitenancy package in our of our client's CRM project along with spatie/laravel-medialibrary.

The default behavior of the media library package is, it generates a folder for each media with its ID in our configured disk, like a public folder or s3 or whatever disk we configured.

This works really great when you are dealing with a single-tenant application. But while using multi-tenant, you got a media table in each of your tenant databases. so this pattern simply doesn't work. Because then you will end up having multiple media files under the same folder from different tenants.

So what we want to do is, instead of having a structure like,

public
-- media
---- 1
------ file.jpg
---- 2
------ file.jpg
...

What we want to achieve is, we want to have a folder structure where media of every tenant will be in a separate folder with tenant unique id,

public
-- media
---- abcd1234 // tenant1 Id
------ 1
-------- file.jpg
------ 2
-------- file.jpg
---- efgh5678 // tenant2 Id
------ 1
-------- file.jpg
------ 2
-------- file.jpg
...

Spatie Media library is very configurable out of the box where you can write your own media library path generator. That is documented very well over here: https://docs.spatie.be/laravel-medialibrary/v8/advanced-usage/using-a-custom-directory-structure

So what we did is, we wrote our own Path Generator, which can store files into tenants folder. Here is how it looks like,

<?php

namespace App\MediaLibrary;

use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator;

class InfyCRMMediaPathGenerator extends DefaultPathGenerator
{
    /*
     * Get a unique base path for the given media.
     */
    protected function getBasePath(Media $media): string
    {
        $currentTenant = app('currentTenant');

        return $currentTenant->unique_id.DIRECTORY_SEPARATOR.$media->getKey();
    }
}

What we did here is, we just simply extended the Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator of Media Library and override the function getBasePath. We attached the prefix of the tenant's unique_id to the path. so instead of 1/file.png, it will return abcd1234/1/file.png.

All you need to make sure is, whenever you are uploading a media, your application should be tenant aware. Otherwise, it will not able to get the current tenant.

Hope this helps while using spatie media library along with spatie multi-tenant.

Even if you are not using a spatie multi-tenant, still you can create your own PathGenerator and use it your own way to have a media structure you want.

July 30, 20202 minutesauthorMitul Golakiya
post
Facebook Login With Firebase In Android Java

1.Add this library build.gradle(:app)

  • This library user for firebase integration dependencies 
  • {
    implementation 'com.google.firebase:firebase-auth:19.4.0'
    }
2.Add this permission in AndroidManifest.xml

  • This permission use internet connection checking
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
3.Below Facebook Button Add on activity xml :

<com.facebook.login.widget.LoginButton
         android:id="@+id/login_button"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_gravity="center"
         android:visibility="gone" />
4.Activity in add this permission

  • This permission user for user data get. Without this permission user data not meet

  • loginButton” This button is Facebook button 

  • LoginManager.getInstance().logInWithReadPermissions(FacebookLoginActivity.this, Arrays.asList("email", "public_profile")); 
  • loginButton.setReadPermissions("email", "public_profile");
5.Initialize Authentication:

void initializeAuthentication(){
                FirebaseAuth  mAuth = FirebaseAuth.getInstance();
             GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
             .requestIdToken(getString(R.string.default_web_client_id))
             .requestEmail()
             .build();
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
}
6.Add This Function:

  • This function user login result return
void faceBookLogin(LoginResult loginResult){
     setFacebookData(loginResult);
     Profile profile = Profile.getCurrentProfile();
     if (profile != null) {
       String avatar =  ImageRequest.getProfilePictureUri(profile.getId(), 200, 200).toString();
   }
   handleFacebookAccessToken(loginResult.getAccessToken());
}
7.Handle Token :

  • This token return firebase login fails or not an event
private void handleFacebookAccessToken(AccessToken token) {
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
           .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
               @Override
               public void onComplete(@NonNull Task<AuthResult> task) {
                   if (task.isSuccessful()) {
                       FirebaseUser user = mAuth.getCurrentUser();
                       user.getIdToken(true).addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
                           @Override
                           public void onComplete(@NonNull Task<GetTokenResult> task) {
                               String token = task.getResult().getToken();

                           }
                       });

                   } else {
                      String errorCode = String.valueOf(task.getException());
                       Toast.makeText(FacebookLoginActivity.this, "Login failed.", Toast.LENGTH_SHORT).show();
                    } 
            }
    });
}
Notes:

  • “Default_web_client_id” this keyword, not changes because creating google-services.json file time automatically this keyword in add values so this key work put at its
How to creating google JSON file : JSON File

Add google JSON file this location in android studio:

July 28, 20201 minuteauthorPankaj Valani