Skip to content

Instantly share code, notes, and snippets.

View csinghdev's full-sized avatar
👨‍💻

Chandresh csinghdev

👨‍💻
View GitHub Profile
https://jennamolby.com/how-to-use-cookies-to-capture-url-parameters/
// Parse the URL
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@csinghdev
csinghdev / .travis.yml
Created July 14, 2020 02:49
Travis-CI configuration file for testing Laravel Application containing REST APIs
language: php
php:
- 7.3
- 7.4
os: linux
before_script:
- composer install
@csinghdev
csinghdev / SendDocLinkToUsers.php
Created June 14, 2020 05:18
Command for sending Doc links to users. File Path: app/Console/Commands/SendDocLinkToUsers.php
<?php
namespace App\Console\Commands;
use App\Notifications\SendDocLinkNotification;
use App\User;
use Illuminate\Console\Command;
class SendDocLinkToUsers extends Command
{
@csinghdev
csinghdev / LogRoute.php
Created May 7, 2020 15:43
Middleware for API Logging - Laravel
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Log;
class LogRoute
{
/**
@csinghdev
csinghdev / UsersTableSeeder.php
Created April 27, 2020 18:18
Simple Users Table Seeder Example
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
@csinghdev
csinghdev / AuthController.php
Created April 16, 2020 15:13
Auth APIs using JWT in Laravel
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AuthController extends Controller
{
public function __construct()
{
@csinghdev
csinghdev / response_builder.php
Created April 12, 2020 13:21
Response builder config file for mapping API code and messages
<?php
use App\ApiCode;
return [
/*
|-----------------------------------------------------------------------------------------------------------
| Code range settings
|-----------------------------------------------------------------------------------------------------------
@csinghdev
csinghdev / api.php
Created April 12, 2020 13:18
Localization file for API Error Messages
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
@csinghdev
csinghdev / ApiCode.php
Created April 12, 2020 12:13
API Codes
<?php
namespace App;
class ApiCode {
 public const SOMETHING_WENT_WRONG = 250;
 public const INVALID_CREDENTIALS = 251;
}
@csinghdev
csinghdev / Controller.php
Last active April 12, 2020 13:12
Response management functions in Controller
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use MarcinOrlowski\ResponseBuilder\ResponseBuilder;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;