Skip to content

Instantly share code, notes, and snippets.

View Faizanq's full-sized avatar

Faizan Qureshi Faizanq

View GitHub Profile
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Mail\WelcomeNewCustomer;
use Illuminate\Support\Facades\Mail;
<?php
namespace App\Models;
use App\Observers\CustomerObserver;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Customer extends Model
{
<?php
namespace App\Observers;
use App\Mail\WelcomeNewCustomer;
use App\Models\Customer;
use Illuminate\Support\Facades\Mail;
<?php
namespace App\Http\Controllers;
use App\Models\Customer;
use App\Http\Requests\NewCustomerRequest;
class CustomerController extends Controller
This is the request validadtion code for post route
https://gist.github.com/Faizanq/3d2b435b7c61fa37f28feb74ddef2daa
Customer Controller Code
https://gist.github.com/Faizanq/f7096495a66080e15c31d6ea55e98b7a
Customer mail observer which is responsible for mail sending
https://gist.github.com/Faizanq/60fd21b3f4c4ee71876fbe2429d5295d
Customer model where we injecting observer for create event
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class NewCustomerRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
<template>
<div class="widget">
<div v-if="activeItems && activeItems.length > 0">
<ul>
<li v-for="item in activeItems" :key="item.id">
{{item.name}}
</li>
</ul>
</div>
</div>
# 7.4
sudo apt-get -y install php-pear php7.4-dev
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4
sudo pecl uninstall -r sqlsrv
@Faizanq
Faizanq / settimeout.php
Created July 9, 2020 10:12 — forked from edwjusti/settimeout.php
setTimeout for php
<?php
class TimeoutClass extends Thread {
public function __construct(callable $cb, int $time, $args){
$this->callback = $cb;
$this->args = $args;
$this->time = $time * 1000;
}
public function run(){
usleep($this->time);
@Faizanq
Faizanq / ID.js
Created June 12, 2020 08:26
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`