Skip to content

Instantly share code, notes, and snippets.

View ollieread's full-sized avatar
👾
Build it all!

Ollie Read ollieread

👾
Build it all!
View GitHub Profile
@ollieread
ollieread / builder.php
Last active February 15, 2022 15:48
Laravel query builder recursive CTE support
<?php
$recursive = $this->query()
->recursive('parents', function (Builder $query) {
$query
->select([
'*',
new Alias('slug', 'fullslug'),
new Alias(0, 'depth'),
new Alias('id', 'tree_id'),
new Alias('name', 'path'),
<?php
$attributes = $productAttributes
->pluck('attributesValues')
->flatten()
->unique()
->groupBy(function (AttributeValue $av) {
return $av->attribute->name;
})
->map(function (Collection $collection) {
+----------+--------------------------------------------------------------+-------------------------------------+
| Method | URI | Name |
+----------+--------------------------------------------------------------+-------------------------------------+
| POST | account | account.create |
| POST | account/identify | account.identify |
| GET|HEAD | account/{account} | account.view |
| PATCH | account/{account} | account.update |
| DELETE | account/{account} | account.delete |
| POST | account/{account}/world | account.world.create
export PATH="~/.composer/vendor/bin:$PATH"
#alias php="/Applications/MAMP/bin/php/php5.5.38/bin/php"
#alias php="phpv"
function php {
CURRENT=`pwd`
if [ -a $CURRENT/.php ]
then
public function uninstall()
{
/*$authnetpm = PaymentMethod::getByHandle('auth_net');
if(is_object($authnetpm)){
$authnetpm->delete();
}
$invoicepm = PaymentMethod::getByHandle('invoice');
if(is_object($invoicepm)){
$invoicepm->delete();
}
@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{
if (event.entity instanceof EntityAgeable) {
EntityAgeable child = (EntityAgeable) event.entity;
if (child.isChild()) {
List parents = child.worldObj.getEntitiesWithinAABBExcludingEntity(child, AxisAlignedBB.getBoundingBox(child.posX, child.posY, child.posZ, child.posX + 4D, child.posY + 4D, child.posZ + 4D));
boolean flag = false;
int parentCount = 0;
<?php
// This would be for the logs model
public function scopeCode($query, $code)
{
return $query->where('code', $code);
}
// Then this would be your main model
public function scopeNotTransferred($query)
if($validator->fails()){
return Response::json(['error' => 1,
'msg'=>$validator->errors()
]);
}
else{
<?php
class Activity
{
public static function log(Model $user, Model $subject, $action)
{
$log = $this->user->logs()-.>create(['action'] => $action]);
$log->subject()->save($subject);
}
<?php
class MyValidator extends BaseValidator
{
public static $rules = [
'create' => [
'field' => ['rule1', 'rule2']
],
'update' => [