Skip to content

Instantly share code, notes, and snippets.

View endihunter's full-sized avatar

Terzi Eduard endihunter

View GitHub Profile
<?php
namespace App\Providers;
use App\User;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
@endihunter
endihunter / routes.php
Created January 26, 2016 08:00
Admin Architect custom routes example
<?php
Route::group([
'prefix' => 'admin',
'namespace' => 'App\Http\Controllers\Admin',
'middleware' => 'auth'
], function () {
Route::group(['prefix' => 'projects'], function () {
Route::get('{project}/finances', [
'as' => "admin.projects.finances",
@endihunter
endihunter / UserPresenters.php
Created January 26, 2016 08:13
Tutorial: User presenters
<?php
namespace App\Traits\Presenters;
use Carbon\Carbon;
trait UserPresenter
{
public function presentName()
{
@endihunter
endihunter / User.php
Created January 26, 2016 08:17
Tutorial: Connecting presenter to a model
<?php
namespace App;
use App\Traits\Auth\HasRoles;
use App\Traits\Presenters\UserPresenter;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Database\Eloquent\SoftDeletes;
@endihunter
endihunter / installation.md
Last active February 25, 2016 10:14
Admin Architect - Installation steps

Admin Architect - Installation steps

  1. copy the contents of zip archive to directory inside your project (for instance: packages), so the final folder structure will look like: packages/administrator/src, etc...

  2. enter to packages/administrator directory and run:

git init; git add . ; git commit -m 'Init';
<?php
namespace {
if (! function_exists('array_build')) {
/**
* Build a new array using a callback (Rriginal method was deprecetad since version 5.2).
*
* @param array $array
* @param callable $callback
<?php
function getId($chunks = 4, $chunkLen = 4) {
$max = pow(36, $chunkLen) - 1;
$id = '';
for ($i = 0; $i < $chunks; ++$i) {
$r = (mt_rand(0, $max) * (microtime(true) * 10000)) / mt_rand(0, $max);
$id .= str_pad(base_convert($r, 10, 36), $chunkLen, "0", STR_PAD_LEFT);
}
@endihunter
endihunter / adminarchitect_relationships
Created October 17, 2016 14:42
adminarchitet relationships usage
Hello.
Nothing can say more than an example :)
Let's say you have a model Post and a Post::user() belongsTo relationship as like as Post::tags() serves as many to many relationship to another tags table.
<?php
namespace App;
<?php
...
public function form()
{
return $this
->scaffoldForm()
->update('fieldname', function ($e) {
return $e->setInput((new \Terranet\Administrator\Form\Type\Key('fieldname')));
});
@endihunter
endihunter / Resources.patch
Created February 6, 2017 13:55
patch a navigation middleware, activate module navigation
From f0f3fe15becb32c85613728c67694b9a0bc91a82 Mon Sep 17 00:00:00 2001
From: Endi <[email protected]>
Date: Mon, 6 Feb 2017 15:52:01 +0200
Subject: [PATCH] Set default active status
---
src/Middleware/Resources.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/Middleware/Resources.php b/src/Middleware/Resources.php