We all know reinventing a wheel concept and Laravel makes it so easy to where we can just plug and play with various packages. Here are some of the essential…


Sometimes you might need to add default params to axios request. I have also faced a similar situation. I thought it might help you too.
I was working on a multilingual app and need to pass the request with the selected language.

I have added @nuxtjs/axios as module. If you haven’t then add @nuxtjs/axios module.

You will need to extend the axios to customize the default behaviour. Then you need to create a file named axios.js inside plugins directory.
Now add your file like the following to your nuxt.config.js

Image for post
Image for post
export default function ({ ctx, $axios, redirect, $auth }) {
$axios.onRequest(config => {
config.params = config.params || {};
//add your params here
config.params['lang'] = window.$nuxt.$i18n.locale; …


If you are trying to create a documentation site then NuxtJS is a very easy way to go. If you haven't tried NuxtJS then it wouldn’t be a problem as it is a powerful framework of VueJS making web development simple and powerful.
Even if you are new to VueJS then you will enjoy the power of VueJS.

Why use the NUXTJS content docs theme?

1. It has blazing fast hot reload in development
2. You can write in a content directory and fetch your Markdown, JSON, YAML, XML, and CSV files through a MongoDB like API, acting as a Git-based Headless CMS
3. It provides a default template for the documentation site which makes the work much easier and fast
4. Even Vue components are supported in markdown
5. Support static site generation with nuxt generate command
6. Syntax highlighting to code blocks in markdown files using PrismJS
7. Automatic Table of contents generation
8. Multilingual Support in the docs theme
9. …


Laravel Eloquent WithWhereHas Mixing with and whereHas using a scope

Image for post
Image for post

I was going with some places where I needed both the with and whereHas and using that in multiple places is not a good practice. So, I tried making that a model scope and reusing wherever needed.

I have also tried to pass dynamic relation, operators, and parameters, single value where parameters or array type so in case it can handle any condition.

What I did was created a model scope like the following:

If you need this scope everywhere in the model then what you do is create a base class model and extend your model with that base class model. Then you can use it everywhere you like.

You can customize it as per your need. Hope it helps you guys.


We always try to do things faster and accidentally we add .idea directory and other unnecessary files.
I have faced this situation mostly for projects where there is no .gitignore generated automatically. Later on, when I try to check the repo from another machine or my team members see it then I feel like Oh! not again!

Here is the code to remove any files if you want to remove it from your git repository.

echo '.idea' >> .gitignore
git rm -r --cached .idea
git add .gitignore
git commit -m 'removed .idea'
git push

If you want to remove any other files or dir then follow the steps like above.

Example: Removing a file name .DS_Store in Mac:

echo '.DS_Store' >> .gitignore 
git rm -r --cached .DS_Store
git add .gitignore
git commit -m 'removed .DS_Store'
git push

Hope it helps you!


Before I start here, I was working with objects and arrays in PHP and other languages. I have been using VueJS these days and always get confused about where to use array or object or convert the object to an array or convert array to object. It is always a dilemma if you are starting to work with javascript.

So, I thought it would help other developers too who have the same thoughts as mine. I am trying to list out all the necessary things while working out with object or array.

Here are some of it and I will keep on updating this one as my use case scenarios. …


If you ever encounter an issue with the incompatible plugin and have installed the plugin in PhpStorm, WebStorm, or any other JetBrains IDE. What I also faced was; I installed a plugin in PhpStorm and that plugin was not compatible with the newer version of PhpStorm.

The Problem:

The strange thing was there was no uninstall option in plugins and was always showing:
“ Plugin Error: Plugin “JSONOnlineViewer” is incompatible (supported only in IntelliJ IDEA).”

I thought it would be gone but it was always showing the issue in the first startup which I found very irritating.

The Solution:

You can always uninstall the plugin from your Mac or Windows or Linux going directly to the installation folder and delete the plugin to solve the issue. …


Image for post
Image for post

If you are planning to move to laravel from any other framework or if your just starting your php framwork on Laravel then installing laravel may get confusing. I have heard about many developers and newbies having this issue for the first time jumping into laravel. The documentation says it all but its not that much clear that everyone can understand it well. Well, here I am again today for you to help to through the process of installation of laravel in easy few steps.

I assume that you have already got your local server running (Wamp, xamp, lamp or any other). If no then please do install one of these or read this tutorial to install the local php, mysql, apache server. …


Image for post
Image for post
Wordpress Pagination

WordPress Pagination is a very essential part for the front, category or archive pages, so you will require you hands on skill on pagination, but it is not as easy as it seems and the documentation for the pagination is not that straightforward if you want page numbers.

Adding the following code into functions.php

function custom_pagination($numpages = '', $pagerange = '', $paged='') {

if (empty($pagerange)) {
$pagerange = 2;
}
global $paged;
if (empty($paged)) {
$paged = 1;
}
if ($numpages == '') {
global $wp_query;
$numpages = $wp_query->max_num_pages;
if(!$numpages) {
$numpages = 1;
}
}

$pagination_args = array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'total' => $numpages,
'current' => $paged,
'show_all' => False,
'end_size' => 1,
'mid_size' => $pagerange,
'prev_next' => True,
'prev_text' => __('«'),
'next_text' => __('»'),
'type' => 'array',
'add_args' => false,
'add_fragment' => ''
);

$paginate_links = paginate_links($pagination_args);

if (is_array($paginate_links)) {
echo "<div class='cpagination'>";
echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . …

About

Bikram KC

Tech Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store