Skip to content

Instantly share code, notes, and snippets.

View elishaukpong's full-sized avatar
🇳🇬
Learning something new somewhere!

Elisha Ukpong elishaukpong

🇳🇬
Learning something new somewhere!
View GitHub Profile
<?php
class User {
protected $firstName;
protected $lastName;
protected $email;
public function setFirstName(string $firstName): self
{
@elishaukpong
elishaukpong / APIEndpoints.php
Last active June 24, 2022 18:41
REST API Endpoints
To Add a lot
POST base_url/sellers/{seller_id}/lots/create
Request Body
{
weight:float|min_weight:500,
country_of_origin:string or id (if list of country db exiss and is seeded),
harvest_date:date_time,
cultivar: string
}
@elishaukpong
elishaukpong / testingTask.php
Created June 24, 2022 17:52
I broke down each separate implementation into their files; running details at the end of the file
//BaseTest.php file name (same convention is followed)
<?php
use PHPUnit\Framework\TestCase;
include'./Hero.php'; // i utilized includes to be swift
class BaseTest extends TestCase
{
public $defender;
<?php
$numbers = [];
foreach(range(1,10) as $index){
$newAddition = mt_rand(1, 100000);
while(in_array($newAddition, $numbers)){
$newAddition = mt_rand(1, 100000);
}
<?php
//With exceptions
try {
$model->name = "Elisha";
$model->save();
} catch(ModelFailedToSaveException $e){
<?php
$name = 'Elisha';
function sayNameInCapital($name){
echo capitalizeText($name);
}
function capitalizeText($text){
class OOPExample
{
public function __construct($name)
{
$this->name = $name;
}
public function sayName(){
echo $this->name;
}
@elishaukpong
elishaukpong / dry-example.php
Created May 1, 2022 23:29
Simple example of DRY
/** BEFORE DRY */
<a href="{{route(sprintf('%s.templateLibrary.index', app()->getLocale()))}">Hello</a>
<a href="{{route(sprintf('%s.templateLibrary.index', app()->getLocale()))}">Hello 2</a>
<a href="{{route(sprintf('%s.templateLibrary.index', app()->getLocale()))}">Hello 3</a>
/** AFTER DRY */
function getRouteString($route){
return route(sprintf("%s.{$route}", app()->getLocale()));
}
const targetNode = document.querySelector('.cff-wrapper-ctn');
const config = { childList: true, subtree: true };
function addBorder(){
const posts = Array.from(document.getElementsByClassName('cff-item'));
posts.forEach(post =>{
let count = parseInt(post.getElementsByClassName('cff-count')[0].innerHTML);
if(count >= 3){
post.style.border = '1px solid black';
@elishaukpong
elishaukpong / DOSpacesStorageServiceProvider.php
Created September 22, 2021 23:18 — forked from m2sh/DOSpacesStorageServiceProvider.php
How To Use Digitalocean Spaces as Laravel Cloud filesystems
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;