Skip to content

Instantly share code, notes, and snippets.

View deepak-cotocus's full-sized avatar

deepak-cotocus

View GitHub Profile
@deepak-cotocus
deepak-cotocus / npm_error_node-sass.md
Last active November 10, 2020 04:52
NPM Error: Node Sass does not yet support your current environment: Linux 64-bit with false

Error:

Error: Node Sass does not yet support your current environment: Linux 64-bit with false

Introduction:

This is because of Node Sass. I got this error in ubuntu machine while running a command npm run prod

Error:

@deepak-cotocus
deepak-cotocus / cross-env-Permission-denied.md
Last active February 29, 2024 07:40
cross-env: Permission denied

Error:

sh: 1: cross-env: Permission denied Ubuntu

Introduction:

This is because of permission issues with global installation of packages, which npm is being denied access. I got this error in ubuntu machine while running a command npm run prod

Error:

@deepak-cotocus
deepak-cotocus / Vue-packages-version-mismatch-error.md
Last active November 5, 2020 09:37
Vue packages version mismatch error fix

Error:

Vue packages version mismatch:

  • vue@2.6.11
  • vue-template-compiler@2.5.16

Introduction:

Though the version of the Vue-template-compiler is older than that of the Vue I just updated it to same version number as the Vue thus 2.6.11 In your case the number might not be same as mine so replace the version which shows in your error.

@deepak-cotocus
deepak-cotocus / EACCES-permission-denied.md
Last active September 15, 2020 11:54
stack Error: EACCES: permission denied

Error: EACCES: permission denied

Introduction:

Once you start deploying your Laravel application you may see this error in your terminal while installing npm.

npm Error:

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/lampp/htdocs/mhn-hospitals-profile-ms/node_modules/node-sass/build'
@deepak-cotocus
deepak-cotocus / resource-collection.md
Last active September 15, 2020 05:31
How to Create Laravel Eloquent API Resources to convert model collections into JSON(Part 5).

Resource Collection

Introduction:

In addition to generating resources that transform individual models, you may generate resources that are responsible for transforming collections of models. This allows your response to include links and other meta information that is relevant to an entire collection of a given resource.

Collection resources extend the Illuminate\Http\Resources\Json\ResourceCollection class:

In previoes lessons we have seen how to generate json data of single object. Now we are going to see how to generatet Collection of Objects.

STEP 1: Command to generate collectionResource class.

@deepak-cotocus
deepak-cotocus / json-resource-without-wrapping.md
Last active August 22, 2020 10:27
How to Create Laravel Eloquent API Resources to convert model collections into JSON(Part 4).

Json resource without wrapping with data key

Introduction:

In the earliear examples i was genreting Json resource which is wrapped with "data:"{} Object like:

Let's generate json resource without data wrapping..

{
"data": {
"id": 3,
@deepak-cotocus
deepak-cotocus / add-additional-information-to-resources.md
Last active August 22, 2020 12:25
How to Create Laravel Eloquent API Resources to convert model collections into JSON(Part 3).

Json Resource with additional information along with standered values in json file

Introduction:

How to generate customized Json data using resource in Laravel with some additional information?

In Our previous tutorial we have seen how to generate customized Json data in which we had generated 2 field values from User tabel of database.

Now, Assuming Requirement: I need a json data of User Table along with below aditional data like

  1. Virsion
  2. attribution
@deepak-cotocus
deepak-cotocus / laravel-api-resources2.md
Last active August 22, 2020 08:06
How to Create Laravel Eloquent API Resources to convert model collections into JSON(Part 2).

Introduction:

How to generate customized Json data using resource in Laravel?

In Our previous tutorial we have seen how to generate json data in which we just did a Direct Map of our User database table.

Now, We are going to play arround Json data as per our requirement. Every Time Requirements will be diffrent Right...... So we are gona generate different numbers of data in many ways... Just go for it Guys...!

@deepak-cotocus
deepak-cotocus / laravel-api-resources.md
Last active August 22, 2020 05:19
How to Create Laravel Eloquent API Resources to convert model collections into JSON(Part 1).

Introduction:

What is API Resources in Laravel

LARAVEL's resource classes allow you to expressively and easily transform your models and model collections into JSON.Basically you can generate a nice json formatted data right from Eloquent. Laravel's resource classes allow you to expressively and easily transform your models and model collections into JSON. Let’s learn how to generate api resources.Consider you have a user table in your database and you want to generate api resources for your User model.Run following command on your terminal window while being on laravel project root directory:

STEP 1: Generating Resources

  • Run this Command to generate a resource class.
  • By default, resources will be placed in the app/Http/Resources directory of your application. Resources extend the Illuminate\Http\Resources\Json\JsonResource class:
@deepak-cotocus
deepak-cotocus / Create-Rest-API-with-Laravel-5.5-Passport-Authentication.md
Last active August 22, 2020 05:18
How to Create API Rest with Laravel 5.5 Passport Authentication (Part 1)

LARAVEL already makes it easy to perform authentication via traditional login forms, but what about APIs? APIs typically use tokens to authenticate users and do not maintain session state between requests. Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Alex Bilbie.

STEP 1: Installation

install Passport via the Composer package manager: composer require laravel/passport=~4.0

STEP 2: Migrate yore Database

The Passport service provider registers its own database migration directory with the framework, so you should migrate your database after registering the provider. The Passport migrations will create the tables your application needs to store clients and access tokens: