Skip to content

Instantly share code, notes, and snippets.

Martin Kluska pionl

Block or report user

Report or block pionl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View GroupedCollection.php
<?php
namespace Pion\Support;
use Illuminate\Support\Collection;
/**
* Class GroupedCollection
*
* Collection that will support adding values with grouped index (collection indexed by groupKey)
*
@pionl
pionl / RelationCountTrait.php
Created Oct 21, 2015
Relation count for Laravel 5 Model with simple usage
View RelationCountTrait.php
<?php
namespace Pion\Traits\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* Trait RelationCountTrait
*
* Usage of where: $count = $model->relationCountWithWhere("user_permission", "user_id", $user, "App\\Models\\User");
@pionl
pionl / NullEmptyStringAttributeTrait.php
Last active May 4, 2016
Enables the automatic nulling of empty string value. You can provide * list of collumns keys to allow only specified collumns to be nulled. Used in Laravel 5 Model.
View NullEmptyStringAttributeTrait.php
<?php
namespace Pion\Traits\Models;
/**
* Class NullEmptyStringAttributeTrait
*
* Enables the automatic nulling of empty string value. You can provide
* list of collumns keys to allow only specified collumns to be nulled.
*
* Usage for setting nullEmptyCollumns:
@pionl
pionl / ModelJoinTrait.php
Last active Jan 5, 2018
Model join trait with Automatic Join on Laravel 5 Eloquent Models with relations setup. With automatic filling relation object if detected
View ModelJoinTrait.php
<?php
namespace Pion\Traits\Models;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Str;
/**
* Class ModelJoinTrait
*
* Trait to create model join for scope with detection of model in the attributes.
@pionl
pionl / contentInsetCenter
Created Sep 4, 2014
First cell starts in center of the view.
View contentInsetCenter
- (CGSize)collectionViewContentSize {
CGSize contentSize = [super collectionViewContentSize];
// we need to center last view
int items = [[self collectionView] numberOfItemsInSection:0];
UICollectionViewLayoutAttributes* layoutAttribute = (UICollectionViewLayoutAttributes*)[super layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:items-1 inSection:0]];
float startX = contentSize.width - self.collectionView.bounds.size.width + self.collectionView.bounds.size.width / 2;
startX = layoutAttribute.frame.origin.x - startX;
You can’t perform that action at this time.