Skip to content

Commit fec3871

Browse files
committed
initial commit for 5.2 support
0 parents  commit fec3871

File tree

925 files changed

+105186
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

925 files changed

+105186
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# LARAVEL BACKEND
2+
3+
Laravel Backend is an instant backend for laravel 5.1~. It is a component base architecture and is very flexible.
4+
5+
### Built-in Components:
6+
- User Management with Roles & Permissions (base on individual module), throotling
7+
- Content Type Builder w/ Custom Fields (inspired from WordPress)
8+
- Navigation Builder
9+
- Media Manager
10+
- (want more?) You can even make your custom component easily aswell!
11+
12+
### WEBSITE
13+
14+
http://laravelbackend.com/
15+
16+
### Todos:
17+
- Improve Docs
18+
19+
## NOTE!
20+
### This software is in alpha and API may change anytime.
21+
### When upgrading, please read carefully the notes on upgrading in each releases to avoid errors!

composer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "darryldecode/laravelbackend",
3+
"description": "Laravel 5 Backend",
4+
"keywords": ["laravel", "laravel admin package", "backend", "administrator", "dashboard", "admin"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Darryl Fernandez",
9+
"email": "engrdarrylfernandez@gmail.com"
10+
}
11+
],
12+
"require": {
13+
"php": ">=5.6.0",
14+
"illuminate/html": "^5.0@dev",
15+
"intervention/image": "^2.3@dev"
16+
},
17+
"require-dev": {
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"Darryldecode\\": "src/Darryldecode"
22+
}
23+
},
24+
"minimum-stability": "dev"
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php namespace Darryldecode\Backend;
2+
3+
use Illuminate\Routing\Router;
4+
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
5+
6+
class BackendRoutesServiceProvider extends ServiceProvider {
7+
8+
/**
9+
* Define your route model bindings, pattern filters, etc.
10+
*
11+
* @param \Illuminate\Routing\Router $router
12+
* @return void
13+
*/
14+
public function boot(Router $router)
15+
{
16+
parent::boot($router);
17+
}
18+
19+
/**
20+
* Define the routes for the application.
21+
*
22+
* @param \Illuminate\Routing\Router $router
23+
* @return void
24+
*/
25+
public function map(Router $router)
26+
{
27+
// register component routes
28+
foreach($this->app['backend']->getRoutes() as $route)
29+
{
30+
$router->group(['prefix' => config('backend.backend.base_url'), 'namespace' => $route['namespace'], 'middleware' => ['web']], function($router) use ($route)
31+
{
32+
require $route['dir'];
33+
});
34+
}
35+
}
36+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php namespace Darryldecode\Backend;
2+
3+
use Darryldecode\Backend\Base\Registrar\ComponentLoader;
4+
use Darryldecode\Backend\Base\Registrar\Registrar;
5+
use Darryldecode\Backend\Base\Registrar\WidgetLoader;
6+
use Illuminate\Filesystem\Filesystem;
7+
use Illuminate\Routing\Router;
8+
use Illuminate\Support\ServiceProvider;
9+
10+
class BackendServiceProvider extends ServiceProvider {
11+
12+
/**
13+
* Register the service provider.
14+
* @param Router $router \Illuminate\Contracts\Http\Kernel
15+
*/
16+
public function boot(Router $router)
17+
{
18+
$this->loadViewsFrom(__DIR__.'/Base/Views', 'backend');
19+
$this->bootBackend();
20+
21+
$router->middleware(
22+
'backend.guest',
23+
'Darryldecode\Backend\Base\Middleware\RedirectIfAuthenticated'
24+
);
25+
26+
$router->middleware(
27+
'backend.authenticated',
28+
'Darryldecode\Backend\Base\Middleware\Authenticate'
29+
);
30+
31+
$this->publishes([
32+
__DIR__.'/Public/backend/cb' => public_path('darryldecode/backend/cb'),
33+
__DIR__.'/Public/backend/vendor' => public_path('darryldecode/backend/vendor'),
34+
], 'public');
35+
36+
$this->publishes([
37+
__DIR__.'/Config' => config_path('backend'),
38+
], 'config');
39+
40+
$this->publishes([
41+
__DIR__.'/Database/Migrations' => database_path('migrations'),
42+
__DIR__.'/Database/Seeders' => database_path('seeds'),
43+
], 'migrations');
44+
45+
$this->publishes([
46+
__DIR__.'/Components/Auth/Views' => base_path('resources/views/backend/auth'),
47+
], 'views');
48+
}
49+
50+
/**
51+
* boot backend
52+
*/
53+
public function bootBackend()
54+
{
55+
// load built-in components
56+
$componentLoader = new ComponentLoader(__DIR__.'/Components', new Filesystem());
57+
$builtInComponents = $componentLoader->getAvailableComponentInstances();
58+
59+
// load custom components
60+
$componentLoader = new ComponentLoader(app_path().'/Backend/Components', new Filesystem());
61+
$customComponents = $componentLoader->getAvailableComponentInstances();
62+
63+
// add those loaded components to backend registrar
64+
$backendRegistrar = new Registrar();
65+
66+
$backendRegistrar->addComponent(array(
67+
$builtInComponents
68+
));
69+
$backendRegistrar->addComponent(array(
70+
$customComponents
71+
));
72+
73+
// this should be in-order
74+
$backendRegistrar->initRoutes();
75+
$backendRegistrar->initViews();
76+
$backendRegistrar->initNavigation();
77+
$backendRegistrar->initPermissions();
78+
$backendRegistrar->initAddHeaderScripts();
79+
$backendRegistrar->initAddFooterScripts();
80+
81+
// load views
82+
foreach($backendRegistrar->getViewsPaths() as $view)
83+
{
84+
$this->loadViewsFrom($view['dir'], $view['namespace']);
85+
}
86+
87+
// load built-in widgets
88+
$builtInWidgetsLoader = new WidgetLoader(__DIR__.'/Widgets', new Filesystem());
89+
$customWidgetsLoader = new WidgetLoader(app_path().'/Backend/Widgets', new Filesystem());
90+
91+
// add widgets
92+
$backendRegistrar->addWidget($builtInWidgetsLoader->getAvailableWidgetInstances());
93+
$backendRegistrar->addWidget($customWidgetsLoader->getAvailableWidgetInstances());
94+
95+
$this->app['backend'] = $backendRegistrar;
96+
}
97+
98+
/**
99+
* Register the service provider.
100+
*
101+
* @return void
102+
*/
103+
public function register()
104+
{
105+
106+
}
107+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php namespace Darryldecode\Backend\Base\Commands;
2+
3+
abstract class Command {
4+
5+
/**
6+
* @var \Darryldecode\Backend\Components\User\Models\User
7+
*/
8+
protected $user;
9+
10+
/**
11+
* the application
12+
*
13+
* @var
14+
*/
15+
protected $app;
16+
17+
/**
18+
* the array of args of the command
19+
*
20+
* @var
21+
*/
22+
protected $args;
23+
24+
/**
25+
* disable the permission checking on a command, this will be helpful
26+
* when the commands are being used as an API or something custom that does not need
27+
* to check a user permission. Just in case you need it to work freely
28+
*
29+
* @var bool
30+
*/
31+
protected $disablePermissionChecking = false;
32+
33+
public function __construct()
34+
{
35+
$app = app();
36+
$this->app = $app;
37+
$this->user = $app['auth']->user();
38+
}
39+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: darryl
5+
* Date: 1/25/2015
6+
* Time: 11:59 AM
7+
*/
8+
9+
namespace Darryldecode\Backend\Base\Commands;
10+
11+
12+
use Illuminate\Support\Collection;
13+
14+
class CommandResult {
15+
16+
/**
17+
* @var bool
18+
*/
19+
protected $success = false;
20+
21+
/**
22+
* @var int
23+
*/
24+
protected $statusCode;
25+
26+
/**
27+
* @var string
28+
*/
29+
protected $message = 'No message set.';
30+
31+
/**
32+
* @var null|mixed
33+
*/
34+
protected $data;
35+
36+
static $responseForbiddenMessage = "Not enough permission.";
37+
static $responseInternalErrorMessage = "An error has occurred on the server.";
38+
39+
/**
40+
* Command result object constructor
41+
*
42+
* @param bool $success
43+
* @param string $message
44+
* @param null $data
45+
* @param int $statusCode
46+
*/
47+
public function __construct($success = false, $message = '', $data = null, $statusCode = 500)
48+
{
49+
$this->success = $success;
50+
$this->message = $message;
51+
$this->statusCode = $statusCode;
52+
$this->data = $data;
53+
}
54+
55+
/**
56+
* determine if command transaction was successful
57+
*
58+
* @return bool
59+
*/
60+
public function isSuccessful()
61+
{
62+
return $this->success;
63+
}
64+
65+
/**
66+
* the status code
67+
*
68+
* @return int
69+
*/
70+
public function getStatusCode()
71+
{
72+
return $this->statusCode;
73+
}
74+
75+
/**
76+
* the command result message
77+
*
78+
* @return string
79+
*/
80+
public function getMessage()
81+
{
82+
return $this->message;
83+
}
84+
85+
/**
86+
* the command result returned data
87+
*
88+
* @return null
89+
*/
90+
public function getData()
91+
{
92+
if( is_null($this->data) ) return new Collection();
93+
94+
if( is_array($this->data) ) return new Collection($this->data);
95+
96+
return $this->data;
97+
}
98+
}

0 commit comments

Comments
 (0)