Initial Release

This commit is contained in:
Deon George 2018-04-23 17:45:21 +10:00
commit 2987e622de
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
16 changed files with 786 additions and 0 deletions

29
composer.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "leenooks/laravel",
"description": "Leenooks standard templates and tools.",
"keywords": ["laravel", "leenooks"],
"license": "MIT",
"authors": [
{
"name": "Deon George",
"email": "deon@leenooks.net"
}
],
"require": {
},
"require-dev": {
},
"autoload": {
"psr-4": {
"Leenooks\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"Leenooks\\Providers\\LeenooksServiceProvider"
]
}
},
"minimum-stability": "dev"
}

View File

@ -0,0 +1,139 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| messages that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/
'logged' => 'You are logged in!',
'someproblems' => 'There were some problems with your input.',
'siginsession' => 'Sign in to start your session',
'remember' => 'Remember Me',
'buttonsign' => 'Sign In',
'forgotpassword' => 'I forgot my password',
'registermember' => 'Register a new membership',
'terms' => 'I agree to the terms',
'conditions' => 'Terms and conditions',
'register' => 'Register',
'login' => 'Login',
'membreship' => 'I already have a membership',
'passwordclickreset' => 'Click here to reset your password:',
'signGithub' => 'Sign in using Github',
'signFacebook' => 'Sign in using Facebook',
'signTwitter' => 'Sign in using Twitter',
'signGoogle+' => 'Sign in using Google+',
'signLinkedin' => 'Sign in using Linkedin',
'signW3id' => 'Sign in using W3id',
'signIBMid' => 'Sign in using IBMid',
'sendpassword' => 'Send Password Reset Link',
'passwordreset' => 'Reset password',
'pagenotfound' => 'Page not found',
'404error' => '404 Error Page',
'notfindpage' => 'We could not find the page you were looking for.',
'mainwhile' => 'Meanwhile, you may',
'returndashboard' => 'return to dashboard',
'usingsearch' => 'or try using the search form.',
'search' => 'Search',
'servererror' => 'Server Error',
'500error' => '500 Error Page',
'somethingwrong' => 'Something went wrong.',
'wewillwork' => 'We will work on fixing that right away.',
'serviceunavailable' => 'Service unavailable',
'503error' => '503 Error Page',
'level' => 'Level',
'here' => 'Here',
'recentactivity' => 'Recent Activity',
'descriptionpackage' => 'A Laravel 5 package that switchs default Laravel scaffolding/boilerplate to AdminLTE template',
'createdby' => 'Created by',
'seecode' => 'See code at',
'online' => 'Online',
'home' => 'Home',
'header' => 'HEADER',
'anotherlink' => 'Another Link',
'multilevel' => 'Multilevel',
'linklevel2' => 'Link in level2',
'birthday' => 'Langdon\'s Birthday',
'birthdaydate' => 'Will be 23 on April 24th',
'progress' => 'Tasks Progress',
'customtemplate' => 'Custom Template Design',
'statstab' => 'Stats Tab Content',
'generalset' => 'General Settings',
'reportpanel' => 'Report panel usage',
'checked' => 'checked',
'informationsettings' => 'Some information about this general settings option',
'togglenav' => 'Toggle navigation',
'tabmessages' => 'You have 4 messages',
'supteam' => 'Support Team',
'awesometheme' => 'Why not buy a new awesome theme?',
'allmessages' => 'See All Messages',
'notifications' => 'You have 10 notifications',
'newmembers' => '5 new members joined today',
'viewall' => 'View all',
'tasks' => 'You have 9 tasks',
'alltasks' => 'View all tasks',
'desbuttons' => 'Design some buttons',
'complete' => 'Complete',
'membersince' => 'Member since',
'followers' => 'Followers',
'sales' => 'Sales',
'friends' => 'Friends',
'profile' => 'Profile',
'signout' => 'Sign out',
'landingdescription' => 'Laravel 5 package that switchs default Laravel scaffolding/boilerplate to AdminLTE template with Bootstrap 3.0 and Pratt Landing page',
'landingdescriptionpratt' => 'Acacha AdminLTE Laravel package template Landing page - Using Pratt',
'description' => 'Description',
'showcase' => 'Showcase',
'contact' => 'Contact',
'laravelpackage' => '5 package that switchs default Laravel',
'to' => 'to',
'templatewith' => 'template with',
'and' => 'and',
'gedstarted' => 'Get Started!',
'amazing' => 'Amazing admin template',
'basedadminlte' => 'Based on adminlte bootstrap theme',
'awesomepackaged' => 'Awesome packaged...',
'by' => 'by',
'at' => 'at',
'readytouse' => 'ready to use with Laravel!',
'designed' => 'Designed To Excel',
'community' => 'Community',
'see' => 'See',
'githubproject' => 'Github project',
'post' => 'post',
'issues' => 'issues',
'pullrequests' => 'Pull requests',
'schedule' => 'Schedule',
'monitoring' => 'Monitoring',
'whatnew' => 'What\'s New?',
'features' => 'Some Features',
'design' => 'First Class Design',
'retina' => 'Retina Ready Theme',
'support' => 'Awesome Support',
'responsive' => 'Responsive Design',
'screenshots' => 'Some Screenshots',
'address' => 'Address',
'dropus' => 'Drop Us A Line',
'yourname' => 'Your Name',
'emailaddress' => 'Email Address',
'enteremail' => 'Enter Email',
'yourtext' => 'Your Text',
'submit' => 'SUBMIT',
'email' => 'Email',
'username' => 'Username',
'password' => 'Password',
'retypepassword' => 'Retype password',
'fullname' => 'Full Name',
'registererror' => 'Error registering!',
'loginerror' => 'Error loging!',
'loggedin' => 'Logged in!',
'entering' => 'Entering...',
'registered' => 'User Registered!',
];

View File

@ -0,0 +1,53 @@
@extends('adminlte::layouts.auth')
@section('htmlheader_title')
Log in
@endsection
@section('content')
<body class="hold-transition login-page">
<div id="app" v-cloak>
<div class="login-box">
<div class="login-logo">
<a href="{{ url('/home') }}">{!! config('app.name_html_long') !!}</a>
</div><!-- /.login-logo -->
@if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> {{ trans('adminlte_lang::message.someproblems') }}<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="login-box-body">
<p class="login-box-msg"> {{ trans('adminlte_lang::message.siginsession') }} </p>
<login-form name="{{ config('auth.providers.users.field','email') }}"
domain="{{ config('auth.defaults.domain','') }}"></login-form>
<a href="{{ url('/password/reset') }}">{{ trans('adminlte_lang::message.forgotpassword') }}</a><br>
@if(count(config('auth.social',[])))
@include('adminlte::auth.partials.social_login')
@endif
</div>
</div>
</div>
@include('adminlte::layouts.partials.scripts_auth')
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
});
</script>
</body>
@endsection

View File

@ -0,0 +1,6 @@
<div class="social-auth-links text-center">
<p>- OR -</p>
@foreach(config('auth.social') as $o)
<a href="{{ url('/auth/'.$o['id']) }}" class="btn btn-block btn-social btn-{{ $o['class'] }} btn-flat"><i class="fa fa-{{ $o['icon'] }}"></i> {{ trans('adminlte_lang::message.sign'.$o['name']) }}</a>
@endforeach
</div><!-- /.social-auth-links -->

View File

@ -0,0 +1,44 @@
@extends('adminlte::layouts.auth')
@section('htmlheader_title')
Register
@endsection
@section('content')
<body class="hold-transition register-page">
<div id="app" v-cloak>
<div class="register-box">
<div class="register-logo">
<a href="{{ url('/home') }}"><b>Pipeline</b>Management</a>
</div>
@if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> {{ trans('adminlte_lang::message.someproblems') }}<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="register-box-body">
<p class="login-box-msg">Register for access</p>
<register-form></register-form>
<!-- #include('adminlte::auth.partials.social_login') -->
<a href="{{ url('/login') }}" class="text-center">I already have an account</a>
</div><!-- /.form-box -->
</div><!-- /.register-box -->
</div>
@include('adminlte::layouts.partials.scripts_auth')
@include('adminlte::auth.terms')
</body>
@endsection

View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
@section('htmlheader')
@include('adminlte::layouts.partials.htmlheader')
@show
<body class="fixed skin-blue sidebar-mini">
<div id="app" v-cloak>
<div class="wrapper">
@include('adminlte::layouts.partials.mainheader')
@include('adminlte::layouts.partials.sidebar')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
@include('adminlte::layouts.partials.contentheader')
<!-- Main content -->
<section class="content">
<div class="row">
<!-- Your Page Content Here -->
@yield('main-content')
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- #include('adminlte::layouts.partials.controlsidebar') -->
@include('adminlte::layouts.partials.footer')
</div><!-- ./wrapper -->
</div> <!-- ./app -->
@section('scripts')
@include('adminlte::layouts.partials.scripts')
{{-- Scripts --}}
{!! Asset::scripts() !!}
@show
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
@include('adminlte::layouts.partials.htmlheader')
@yield('content')
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
@include('adminlte::layouts.partials.htmlheader')
<body>
<div id="app" v-cloak>
<!-- Main content -->
<section class="content">
<!-- Your Page Content Here -->
@yield('main-content')
</section>
</div>
@section('scripts')
@include('adminlte::layouts.partials.scripts')
@show
</body>
</html>

View File

@ -0,0 +1,41 @@
<head>
<meta charset="UTF-8">
<title>{{ config('app.name') }} - @yield('htmlheader_title', 'Your title here') </title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<link href="{{ asset('/css/all.css') }}" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
//See https://laracasts.com/discuss/channels/vue/use-trans-in-vuejs
window.trans =
@php
// copy all translations from /resources/lang/CURRENT_LOCALE/* to global JS variable
$lang_files = File::files(resource_path() . '/lang/' . App::getLocale());
$trans = [];
foreach ($lang_files as $f) {
$filename = pathinfo($f)['filename'];
$trans[$filename] = trans($filename);
}
$trans['adminlte_lang_message'] = trans('adminlte_lang::message');
echo json_encode($trans);
@endphp
</script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<style>
#favourite.selected {
color: orange;
}
</style>
<!-- STYLESHEETS -->
{!! Asset::styles() !!}
</head>

View File

@ -0,0 +1,95 @@
<!-- Main Header -->
<header class="main-header">
<!-- Logo -->
<a href="{{ url('/home') }}" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini">{!! config('app.name_html_short','<b>A</b>N') !!}</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg">{!! config('app.name_html_long','<b>App</b>Name') !!}</span>
</a>
<!-- Header Navbar -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">{{ trans('adminlte_lang::message.togglenav') }}</span>
</a>
<!-- Navbar Right Menu -->
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- Tasks Menu -->
@if (Auth::guest())
<li><a href="{{ url('/register') }}">{{ trans('adminlte_lang::message.register') }}</a></li>
<li><a href="{{ url('/login') }}">{{ trans('adminlte_lang::message.login') }}</a></li>
@else
@if (isset($topmenu))
<!-- Available Data Menu -->
<li class="dropdown tasks-menu" id="import_date">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="hidden-xs">Items</span>
</a>
<ul class="dropdown-menu">
<li class="header">Header</li>
<li>
<ul class="menu small">
&nbsp;
</ul>
</li>
<li class="footer"><a href="#">(Not Active)</a></li>
</ul>
</li>
@endif
<li class="dropdown user user-menu" id="user_menu">
<!-- Menu Toggle Button -->
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<!-- The user image in the navbar-->
<img src="{{ Gravatar::get($user->email) }}" class="user-image" alt="User Image"/>
<!-- hidden-xs hides the username on small devices so only the image appears. -->
<span class="hidden-xs">{{ $user->name }}</span>
</a>
<ul class="dropdown-menu">
<!-- The user image in the menu -->
<li class="user-header">
<img src="{{ Gravatar::get($user->email) }}" class="img-circle" alt="User Image" />
<p>
{{ $user->name }}
<small>{{ trans('adminlte_lang::message.login') }}: @if($user->last_access) {{ $user->last_access->format('Y-m-d') }} @else Unknown @endif</small>
</p>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<a href="{{ url('/settings') }}" class="btn btn-default btn-flat">{{ trans('adminlte_lang::message.profile') }}</a>
</div>
<div class="pull-right">
<a href="{{ url('/logout') }}" class="btn btn-default btn-flat" id="logout"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ trans('adminlte_lang::message.signout') }}
</a>
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
<input type="submit" value="logout" style="display: none;">
</form>
</div>
</li>
</ul>
</li>
@endif
<!-- Control Sidebar Toggle Button -->
@if (isset($controlbar))
<li>
<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
</li>
@endif
</ul>
</div>
</nav>
</header>

View File

@ -0,0 +1,2 @@
<!-- Compiled app javascript -->
<script src="{{ url (mix('/js/app.js')) }}"></script>

View File

@ -0,0 +1,108 @@
<!-- Left side column. contains the logo and sidebar -->
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- Sidebar user panel (optional) -->
@if (! Auth::guest())
<div class="user-panel">
<div class="pull-left image">
<img src="{{ Gravatar::get($user->email) }}" class="img-circle" alt="User Image" />
</div>
<div class="pull-left info">
<p>{{ Auth::user()->name }}</p>
<!-- Status -->
<a href="#"><i class="fa fa-circle text-success"></i> {{ trans('adminlte_lang::message.online') }}</a>
</div>
</div>
@endif
<!-- search form (Optional) -->
<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" autocomplete="off" placeholder="{{ trans('adminlte_lang::message.search') }}..."/>
<span class="input-group-btn">
<button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
<!-- /.search form -->
<!-- Sidebar Menu -->
<ul class="sidebar-menu" data-widget="tree">
<li class="header">Menu</li>
<!-- Optionally, you can add icons to the links -->
<li class="active"><a href="{{ url('home',['date'=>(isset($ido) ? $ido->id : NULL)]) }}"><i class='fa fa-link'></i> <span>{{ trans('adminlte_lang::message.home') }}</span></a></li>
</ul><!-- /.sidebar-menu -->
</section>
<!-- /.sidebar -->
</aside>
@section('page-scripts')
<script src="{{ url('/plugins/bootstrap3-typeahead.min.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$("input[name=q]").typeahead({
delay: 300,
minLength: 2,
fitToElement: false,
appendTo: "#search_results",
source: function (query,process) {
search('{{ url("search",['date'=>isset($ido) ? $ido->id : NULL]) }}',query,process);
},
matcher: function () { return true; },
updater: function (item) {
window.parent.location.href = '{{ url("/") }}'+users[item];
},
});
});
var c=0;
var search = _.debounce(function(url,query,process,icon){
$.ajax({
url : url,
type : 'GET',
data : 'term=' + query,
dataType : 'JSON',
async : false,
cache : false,
beforeSend : function() {
if (c++ == 0) {
if (icon)
$('i[name='+icon+']').addClass("fa-spin");
else
$('i[name=searching]').removeClass("hidden");
}
},
success : function(data) {
// if json is null, means no match, won't do again.
if(data==null || (data.length===0)) return;
users = {};
userLabels = [];
_.each(data,function(item,ix,list) {
if (_.includes(users,item.label))
item.label = item.label + ' #' + item.value;
userLabels.push(item.label);
users[item.label] = item.value;
});
process(userLabels);
},
complete : function() {
if (--c == 0) {
if (icon)
$('i[name='+icon+']').removeClass("fa-spin");
else
$('i[name=searching]').addClass("hidden");
}
}
})
}, 500);
</script>
@append

56
src/Carbon.php Normal file
View File

@ -0,0 +1,56 @@
<?php
namespace Leenooks;
use Carbon\Carbon as CarbonBase;
/**
* This overrides the default Carbon\Carbon class so that we can enable
* additional Date functions, like Half Years
*/
class Carbon extends CarbonBase
{
const MONTHS_PER_HALF = 6;
public function __get($name)
{
switch (true) {
case $name === 'half':
return (int) ceil($this->month / static::MONTHS_PER_HALF);
default:
return parent::__get($name);
}
}
/**
* Modify to the first occurrence of a given day of the week
* in the current quarter. If no dayOfWeek is provided, modify to the
* first day of the current quarter. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int|null $dayOfWeek
*
* @return static
*/
public function firstOfHalf($dayOfWeek = null)
{
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF - 5, 1)->firstOfMonth($dayOfWeek);
}
/**
* Modify to the last occurrence of a given day of the week
* in the current quarter. If no dayOfWeek is provided, modify to the
* last day of the current quarter. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int|null $dayOfWeek
*
* @return static
*/
public function lastOfHalf($dayOfWeek = null)
{
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF, 1)->lastOfMonth($dayOfWeek);
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace Leenooks\Providers;
#use Acacha\User\Http\Middleware\GuestUser;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
/**
* Class GuestUserServiceProvider.
*
* @package Acacha\User\Providers
*/
class LeenooksServiceProvider extends ServiceProvider
{
private $_path = '';
/**
* Bootstrap the application services.
*
* @param Router $router
*/
public function boot(Router $router)
{
$this->loadViewsFrom($this->_path.'/resources/themes/adminlte/views/', 'adminlte');
# $this->loadViewsFrom($this->_path.'/resources/views/', 'adminlte');
$this->loadTranslationsFrom($this->_path.'/resources/themes/adminlte/lang/', 'adminlte_lang');
//dd($this->views());
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
if (! $this->_path) {
$this->_path = realpath(__DIR__.'/../../');
define('LEENOOKS',realpath(__DIR__.'/../../'));
}
//$this->publishes($this->views());
}
/**
* Views copy path.
*
* @return array
*/
public function views()
{
return [
LEENOOKS.'/resources/views/auth' =>
resource_path('views/vendor/adminlte/auth'),
$this->_path.'/resources/views/errors' =>
resource_path('views/vendor/adminlte/errors'),
$this->_path.'/resources/views/layouts' =>
resource_path('views/vendor/adminlte/layouts'),
$this->_path.'/resources/views/home.blade.php' =>
resource_path('views/vendor/adminlte/home.blade.php'),
$this->_path.'/resources/views/welcome.blade.php' =>
resource_path('views/welcome.blade.php'),
];
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Collapse a collection, by summing up fields.
*/
namespace Leenooks\Traits;
use Illuminate\Support\Collection;
trait CollectionCollapse {
/**
* Collapse a collection by summing up records according to a given key
*
* @param Collection $c Collection to collapse
* @param array $id To use as the group by key
* @param array $consolidateKeys Keys that should be summed up during the process
* @return Collection
*/
protected function collapse(Collection $c,array $id,array $consolidateKeys=[])
{
return $c->groupBy(function ($item,$key) use ($id) {
$string = '';
foreach ($id as $key) {
if ($string AND array_get($item,$key))
$string .= '.';
$string .= $item[$key];
}
return $string;
})->transform(function ($items,$key) use ($consolidateKeys) {
$newitem = [];
if ($items->count()) {
$c = 0;
foreach ($items as $item) {
if (! $c++) {
$newitem = $item;
continue;
}
foreach ($item as $k => $v) {
// Add these values to the existing ones
if (in_array($k, $consolidateKeys)) {
if (!isset($newitem[$k]))
$newitem[$k] = 0;
$newitem[$k] += $v;
}
}
}
} else {
$newitem = $items;
}
return $newitem;
});
}
}

19
src/Traits/ModelCache.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Traits adds our standing cache functions
*/
namespace Leenooks\Traits;
trait ModelCache
{
// Time to cache calculations for
private $cachetime = 10080; // a week
/**
* Auto calculate a cache key
*/
private function cachekey($method,$one,$two=NULL) {
return md5(sprintf('%s:%s:%s',$method,$one,$two ? $two : $this->id));
}
}