Posts

Laravel: How to Paginate Collection

Image
  Understanding how Laravel Paginator works If we dive into Laravel’s query builder source code: I will briefly explain what Laravel is doing here line by line. Resolving the current page number in the query metadata. Resolving the chunking size ($perPage parameter). Splitting the query results into chunks and get the specific chunk/page that we are after. Generate a paginator response which includes the pagination metadata and result chunk. As seen in step 3, Laravel collection class provides a sweet forPage()  method , which does the chunking and page retrieving for the paginator. Hmm…Let’s see if we can utilise that. Creating a helper class Let’s create our own collection helper class as shown below. I borrowed the paginator function from Laravel’s query builder class to return the same pagination response as Eloquent. Here’s what happening in our paginate method: Resolve current page number in the query metadata. We used the forPage() method to chunk the query results pass...

Error: Cannot create file xampp-control.ini Access is denied

  First,   open your XAMPP folder and find a  xampp-control.ini (D:\xampp\xampp-control.exe) file. right-click on this file and Select  Properties  a tab will open and select  Compatibility  then checkbox check  Run this program as an administrator  and click on the bottom  Ok  button.

Create laravel react project

 composer create-project --prefer-dist laravel/laravel myTask cd myTask composer require laravel/ui php artisan ui bootstrap php artisan ui react composer require laravel/breeze php artisan breeze:install react npm install ------------------  composer create-project --prefer-dist laravel/laravel employee_mgt cd employee_mgt php artisan serve create database name: employee_mgt change in .env file db info

Installing Laravel Breeze and a Quick Walkthrough

Image
  Hello Everyone 👋 In this article, I'm going to install Laravel Breeze and take you in a very quick tour. Laravel Breeze is a very simple implementation of all of Laravel's authentication features, including login, registration, password reset, email verification, and password confirmation. Laravel Breeze's default view layer is made up of simple Blade templates styled with Tailwind CSS. I already wrote about installing TailwindCSS in Laravel project and you can check out the article by clicking  here . This article works as a step by step guide with all the tiny details, so follow along for the best result 👇 1- Install Nodejs and npm: First thing you need to make sure that you have Node and npm installed on your machine. You can check that by opening up the terminal and type those two commands: npm -v node -v If you need to install them 🔗  DOCs for downloading Node and npm If you got that converged, move on 👇 2- Install Database Management Tool: I use free version o...

How To Find a File In Linux From the Command Line

Image
  Locate Linux Files by Their Name or Extension Type find into the command line to track down a particular file by its name or extension. If you want to look for *.err files in the /home/username/ directory and all sub-directories, try this: find /home/username/ -name "*.err" Typical Linux Find Commands and Syntax find command expressions look like this: find command options starting/path expression The options attribute controls the behavior and optimization method of the find process. The starting/path attribute defines the top-level directory where the find command in Linux begins the filtering process. The expression attribute controls the assessments that scour the directory tree to create output. Let’s break down a Linux find command where we don’t just want Linux find file by name: find -O3 -L /var/www/ -name "*.html" It enables the top-level optimization (-O3) and permits find to follow symbolic links (-L). The find command in Linux...

How to Install and Use Wine on Ubuntu 20.04

Image
 Wine is an open-source compatibility layer that allows you to run Windows applications on Unix-like operating systems such as Linux, FreeBSD, and macOS. Wine is an acronym for “Wine Is Not an Emulator”. It translates Windows system calls into equivalent POSIX calls used by Unix-based operating systems, allowing you to seamlessly integrate Windows programs into your desktop environment. Not all Windows applications will run in Wine, and even if they do, they may not behave in the same way they normally would. The Wine AppDB is a database containing a list of applications that have been tested and confirmed to work under Wine. Wine isn’t always the best option to run Windows programs on Linux. You can also use a virtualization tool like VirtualBox or VMware , but they require more system resources and a Windows installation file. This article describes how to install Wine on Ubuntu 20.04. We will show you how to install the distro default version 5.0 and the latest vers...

1.5 Getting Started - Installing Git

Image
  Installing Git Before you start using Git, you have to make it available on your computer. Even if it’s already installed, it’s probably a good idea to update to the latest version. You can either install it as a package or via another installer, or download the source code and compile it yourself. Note This book was written using Git version 2.8.0 . Though most of the commands we use should work even in ancient versions of Git, some of them might not or might act slightly differently if you’re using an older version. Since Git is quite excellent at preserving backwards compatibility, any version after 2.8 should work just fine. Installing on Linux If you want to install the basic Git tools on Linux via a binary installer, you can generally do so through the package management tool that comes with your distribution. If you’re on Fedora (or any closely-related RPM-based distribution, such as RHEL or CentOS), you can use dnf : $ sudo dnf install git-...