Skip to content

Instantly share code, notes, and snippets.

View EricMcWinNer's full-sized avatar
😴
Sleeping... If it's important, dream it to me

Eric Aprioku (Eric McWinNEr) EricMcWinNer

😴
Sleeping... If it's important, dream it to me
View GitHub Profile
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* Get the user's first name.
@EricMcWinNer
EricMcWinNer / classname.js
Created July 2, 2021 16:06
My implementation of className, to allow more fluent class-binding in React
export const classBinding = obj => {
let classString = "";
if (Array.isArray(obj)) {
classString += obj.reduce((carry, item) => {
if ((typeof item === "string" || typeof item === "number") && item)
return `${carry}${carry ? " " : ""}${item}`;
else if (item) return `${carry}${carry ? " " : ""}${classBinding(item)}`;
else return carry + "";
}, "");
} else {
<?php
namespace App\Http\Controllers;
use App\Models\Broker;
class RandomController extends Controller {
public function getWallet(){
$broker = Broker::find(1); // Get a Broker Instance
$wallet = $broker->wallet; // Get the Wallet that this Broker has
// Do whatever with it
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
/**
* Get the company's wallet
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Broker extends Model
{
/**
* Get the broker's wallet
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Wallet extends Model
{
/**
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Wallet extends Model
{
/**
* Get the owner of the relationship which could either be a broker or a company
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
/**
* Get this company's document
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Broker extends Model
{
/**
* Get the owner of the relationship which could either be a broker or a company
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Document extends Model
{
/**
* Get the owner of the relationship which could either be a broker or a company