Skip to content

Commit 49b1a4a

Browse files
committed
initial commit for 3.x.x
0 parents  commit 49b1a4a

File tree

930 files changed

+105693
-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.

930 files changed

+105693
-0
lines changed

.gitignore

+4
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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# LARAVEL BACKEND 2.0~
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+
### Compatibility:
17+
18+
for laravel 5.2
19+
20+
### Todos:
21+
- Improve Docs
22+
23+
## NOTE!
24+
### When upgrading, please read carefully the notes on upgrading in each releases to avoid errors!

composer.json

+25
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": "[email protected]"
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
* @return void
12+
*/
13+
public function boot()
14+
{
15+
parent::boot();
16+
}
17+
18+
/**
19+
* Define the routes for the application.
20+
*
21+
* @return void
22+
*/
23+
public function map()
24+
{
25+
// register component routes
26+
foreach($this->app['backend']->getRoutes() as $route)
27+
{
28+
$this->app['router']->group(['prefix' => config('backend.backend.base_url'), 'namespace' => $route['namespace'], 'middleware' => ['web']], function($router) use ($route)
29+
{
30+
require $route['dir'];
31+
});
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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\Support\ServiceProvider;
8+
use Darryldecode\Backend\Base\Services\Bus\Dispatcher;
9+
10+
class BackendServiceProvider extends ServiceProvider {
11+
12+
/**
13+
* Register the service provider.
14+
*/
15+
public function boot()
16+
{
17+
$this->loadViewsFrom(__DIR__.'/Base/Views', 'backend');
18+
$this->bootBackend();
19+
20+
// $this->app['router']->middleware(
21+
// 'backend.guest',
22+
// 'Darryldecode\Backend\Base\Middleware\RedirectIfAuthenticated'
23+
// );
24+
//
25+
// $this->app['router']->middleware(
26+
// 'backend.authenticated',
27+
// 'Darryldecode\Backend\Base\Middleware\Authenticate'
28+
// );
29+
30+
$this->publishes([
31+
__DIR__.'/Public/backend/cb' => public_path('darryldecode/backend/cb'),
32+
__DIR__.'/Public/backend/vendor' => public_path('darryldecode/backend/vendor'),
33+
], 'public');
34+
35+
$this->publishes([
36+
__DIR__.'/Config' => config_path('backend'),
37+
], 'config');
38+
39+
$this->publishes([
40+
__DIR__.'/Database/Migrations' => database_path('migrations'),
41+
__DIR__.'/Database/Seeders' => database_path('seeds'),
42+
], 'migrations');
43+
44+
$this->publishes([
45+
__DIR__.'/Components/Auth/Views' => base_path('resources/views/backend/auth'),
46+
], 'views');
47+
}
48+
49+
/**
50+
* boot backend
51+
*/
52+
public function bootBackend()
53+
{
54+
// load built-in components
55+
$componentLoader = new ComponentLoader(__DIR__.'/Components', new Filesystem());
56+
$builtInComponents = $componentLoader->getAvailableComponentInstances();
57+
58+
// load custom components
59+
$componentLoader = new ComponentLoader(app_path().'/Backend/Components', new Filesystem());
60+
$customComponents = $componentLoader->getAvailableComponentInstances();
61+
62+
// add those loaded components to backend registrar
63+
$backendRegistrar = new Registrar();
64+
65+
$backendRegistrar->addComponent(array(
66+
$builtInComponents
67+
));
68+
$backendRegistrar->addComponent(array(
69+
$customComponents
70+
));
71+
72+
// this should be in-order
73+
$backendRegistrar->initRoutes();
74+
$backendRegistrar->initViews();
75+
$backendRegistrar->initNavigation();
76+
$backendRegistrar->initPermissions();
77+
$backendRegistrar->initAddHeaderScripts();
78+
$backendRegistrar->initAddFooterScripts();
79+
80+
// load views
81+
foreach($backendRegistrar->getViewsPaths() as $view)
82+
{
83+
$this->loadViewsFrom($view['dir'], $view['namespace']);
84+
}
85+
86+
// load built-in widgets
87+
$builtInWidgetsLoader = new WidgetLoader(__DIR__.'/Widgets', new Filesystem());
88+
$customWidgetsLoader = new WidgetLoader(app_path().'/Backend/Widgets', new Filesystem());
89+
90+
// add widgets
91+
$backendRegistrar->addWidget($builtInWidgetsLoader->getAvailableWidgetInstances());
92+
$backendRegistrar->addWidget($customWidgetsLoader->getAvailableWidgetInstances());
93+
94+
$this->app['backend'] = $backendRegistrar;
95+
}
96+
97+
/**
98+
* Register the service provider.
99+
*
100+
* @return void
101+
*/
102+
public function register()
103+
{
104+
$this->app->singleton('Darryldecode\Backend\Base\Services\Bus\Dispatcher', function ($app) {
105+
return new Dispatcher($app);
106+
});
107+
$this->app->alias(
108+
'Darryldecode\Backend\Base\Services\Bus\Dispatcher', 'Darryldecode\Backend\Base\Contracts\Bus\Dispatcher'
109+
);
110+
}
111+
}
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+
}
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)