Skip to content

Instantly share code, notes, and snippets.

View aphoe's full-sized avatar

afolabi legunsen aphoe

View GitHub Profile
@aphoe
aphoe / MakeRepository.php
Created August 16, 2021 01:12
Laravel command to create repository file, if using the repository pattern
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class MakeRepository extends Command
{
/**
* The name and signature of the console command.
@aphoe
aphoe / implode-and.php
Last active May 14, 2020 14:33
PHP function to 'implode' array into a sentence, using 'and' before the last item
<?php
if(!function_exists('implodeAnd')){
/**
* Implode array into asentence
* @param array $haystack
* @param string $glue
* @param string $and
* @return string
*/
function implodeAnd(array $haystack, string $glue=', ', string $and = ' and '): string
@aphoe
aphoe / checkRoute.php
Last active July 23, 2020 23:20
Function to check if a route exists in Laravel 5
/**
* @param $route
* @return bool
*/
function checkRoute($route) {
$routes = \Route::getRoutes()->getRoutes();
foreach($routes as $r){
if($r->getUri() == $route){
return true;
}