Skip to content

Instantly share code, notes, and snippets.

View einnar82's full-sized avatar
🎯
Doing nice things.

Rannie Ollit einnar82

🎯
Doing nice things.
View GitHub Profile
@einnar82
einnar82 / RegistrationDetails.php
Last active November 12, 2019 06:40
Added error handling in Laravel Mail
<?php
namespace App\Mail\API;
use App\Events\API\MessageSending;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@einnar82
einnar82 / BaseRepositoryContract.php
Created November 18, 2019 03:29
Base Repository interface
<?php
namespace App\Contracts;
interface BaseRepositoryContract
{
public function create(array $attributes);
public function update(array $attributes, int $id);
public function all($columns = array('*'), string $orderBy = 'id', string $sortBy = 'desc');
public function find(int $id);
public function findOneOrFail(int $id);
@einnar82
einnar82 / .gitlab-ci.yml
Last active February 24, 2020 02:17
Basic CI / CD config file in Gitlab
image: registry.gitlab.com/sample/sample-repo:latest
stages:
- preparation
- building
- testing
variables:
MYSQL_DATABASE: api
MYSQL_ROOT_PASSWORD: password
@einnar82
einnar82 / OAuthClient.php
Last active May 3, 2020 11:57
Revoke access token manually in Laravel Passport (Laravel 6.x)
<?php
namespace App\Models;
use Illuminate\Support\Facades\Request as RequestFacade;
use Illuminate\Http\Request;
use Laravel\Passport\Client;
use Laravel\Passport\Token;
use Lcobucci\JWT\Parser;
@einnar82
einnar82 / User.php
Last active January 2, 2020 05:58
Eloquent from database to database (Single database instance) - Part 1
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
@einnar82
einnar82 / Post.php
Last active January 2, 2020 05:57
Eloquent from database to database (Single database instance) - Part 2
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
protected $guarded = ['id'];
@einnar82
einnar82 / database.php
Last active January 2, 2020 02:54
Eloquent from database to database (Single database instance) - Part 3
<?php
use Illuminate\Support\Str;
return [
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'mysql' => [
@einnar82
einnar82 / 2020_01_02_022151_create_posts_table.php
Last active January 9, 2020 07:07
Eloquent from database to database (Single database instance) - Part 4
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTable extends Migration
{
/**
* The database schema.
@einnar82
einnar82 / person.py
Created January 5, 2020 23:53
Spread operator in Python (Part 1)
class Person:
def __init__(self, firstName, lastName, age):
self.firstName = firstName
self.lastName = lastName
self.age = age
def getFirstName(self):
return self.firstName
def getLastName(self):
@einnar82
einnar82 / hr.py
Last active January 6, 2020 00:04
Spread operator in Python (Part 2)
from person import Person
class HR(Person):
def getFullName(self):
return "Mr/Ms " + self.firstName + " " + self.lastName
def getKeywordedArgs(self, **kwargs):
# The double asterisk form is used to pass a keyworded, variable-length argument list.
a, b = kwargs