Skip to content

Commit

Permalink
Adding the main stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Nov 12, 2016
1 parent f1cf19c commit a6447b4
Show file tree
Hide file tree
Showing 13 changed files with 440 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config/media.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/* ------------------------------------------------------------------------------------------------
| Route
| ------------------------------------------------------------------------------------------------
*/
'route' => [
'prefix' => 'media',
],
];
16 changes: 16 additions & 0 deletions config/sidebar/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Arcanesoft\Auth\Models\Role;
use Arcanesoft\Auth\Policies;

return [
'title' => 'Media',
'name' => 'media',
'route' => 'media::foundation.index',
'icon' => 'fa fa-fw fa-picture-o',
'roles' => [Role::ADMINISTRATOR],
'permissions' => [],
'children' => [
//
],
];
12 changes: 12 additions & 0 deletions resources/views/manager.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@section('header')
<h1><i class="fa fa-fw fa-picture-o"></i> Media</h1>
@endsection

@section('content')
@endsection

@section('modals')
@endsection

@section('scripts')
@endsection
45 changes: 45 additions & 0 deletions src/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php namespace Arcanesoft\Media\Http\Controllers;

use Arcanesoft\Core\Bases\FoundationController as BaseController;
use Arcanesoft\Core\Traits\Notifyable;

/**
* Class Controller
*
* @package Arcanesoft\Auth\Http\Controllers\Foundation
* @author ARCANEDEV <[email protected]>
*/
abstract class Controller extends BaseController
{
/* ------------------------------------------------------------------------------------------------
| Traits
| ------------------------------------------------------------------------------------------------
*/
use Notifyable;

/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* The view namespace.
*
* @var string
*/
protected $viewNamespace = 'media';

/* ------------------------------------------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
*/
/**
* Instantiate the controller.
*/
public function __construct()
{
parent::__construct();

$this->addBreadcrumbRoute('Media', 'media::foundation.index');
}
}

35 changes: 35 additions & 0 deletions src/Http/Controllers/MediasController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php namespace Arcanesoft\Media\Http\Controllers;

/**
* Class MediasController
*
* @package Arcanesoft\Media\Http\Controllers
* @author ARCANEDEV <[email protected]>
*/
class MediasController extends Controller
{
/* ------------------------------------------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
*/
/**
* MediasController constructor.
*/
public function __construct()
{
parent::__construct();

$this->setCurrentPage('media');
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
public function index()
{
$this->setTitle('Media');

return $this->view('manager');
}
}
30 changes: 30 additions & 0 deletions src/Http/Routes/MediaRoutes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php namespace Arcanesoft\Media\Http\Routes;

use Arcanedev\Support\Bases\RouteRegister;
use Illuminate\Contracts\Routing\Registrar;

/**
* Class MediaRoutes
*
* @package Arcanesoft\Media\Http\Routes
* @author ARCANEDEV <[email protected]>
*/
class MediaRoutes extends RouteRegister
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Map routes.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
public function map(Registrar $router)
{
$this->get('/', [
'as' => 'index', // media::foundation.index
'uses' => 'MediasController@index',
]);
}
}
84 changes: 84 additions & 0 deletions src/MediaServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php namespace Arcanesoft\Media;

use Arcanesoft\Core\Bases\PackageServiceProvider;
use Arcanesoft\Core\CoreServiceProvider;

/**
* Class MediaServiceProvider
*
* @package Arcanesoft\Media
* @author ARCANEDEV <[email protected]>
*/
class MediaServiceProvider extends PackageServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* Package name.
*
* @var string
*/
protected $package = 'media';

/* ------------------------------------------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
* Get the base path of the package.
*
* @return string
*/
public function getBasePath()
{
return dirname(__DIR__);
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Register the service provider.
*/
public function register()
{
$this->registerConfig();
$this->registerSidebarItems();
$this->app->register(CoreServiceProvider::class);
$this->app->register(Providers\PackagesServiceProvider::class);
$this->app->register(Providers\AuthorizationServiceProvider::class);

if ($this->app->runningInConsole()) {
$this->app->register(Providers\CommandServiceProvider::class);
}
}

/**
* Boot the service provider.
*/
public function boot()
{
$this->app->register(Providers\RouteServiceProvider::class);

// Publishes
$this->publishConfig();
$this->publishViews();
$this->publishTranslations();
$this->publishSidebarItems();
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
//
];
}
}
8 changes: 8 additions & 0 deletions src/Providers/AuthorizationServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php namespace Arcanesoft\Media\Providers;

use Arcanedev\Support\ServiceProvider;

class AuthorizationServiceProvider extends ServiceProvider
{

}
8 changes: 8 additions & 0 deletions src/Providers/CommandServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php namespace Arcanesoft\Media\Providers;

use Arcanedev\Support\ServiceProvider;

class CommandServiceProvider extends ServiceProvider
{

}
8 changes: 8 additions & 0 deletions src/Providers/PackagesServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php namespace Arcanesoft\Media\Providers;

use Arcanedev\Support\ServiceProvider;

class PackagesServiceProvider extends ServiceProvider
{

}
64 changes: 64 additions & 0 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php namespace Arcanesoft\Media\Providers;

use Arcanesoft\Core\Bases\RouteServiceProvider as ServiceProvider;
use Arcanesoft\Media\Http\Routes;
use Illuminate\Contracts\Routing\Registrar as Router;
use Illuminate\Support\Arr;

class RouteServiceProvider extends ServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
* Get the routes namespace
*
* @return string
*/
protected function getRouteNamespace()
{
return 'Arcanesoft\\Auth\\Http\\Routes';
}

/**
* Get the auth foundation route prefix.
*
* @return string
*/
public function getFoundationAuthPrefix()
{
$prefix = Arr::get($this->getFoundationRouteGroup(), 'prefix', 'dashboard');

return "$prefix/" . config('arcanesoft.media.route.prefix', 'media');
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Define the routes for the application.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
public function map(Router $router)
{
$this->mapFoundationRoutes($router);
}

private function mapFoundationRoutes(Router $router)
{
$attributes = array_merge($this->getFoundationRouteGroup(), [
'as' => 'media::foundation.',
'namespace' => 'Arcanesoft\\Media\\Http\\Controllers',
]);

$router->group(array_merge(
$attributes,
['prefix' => $this->getFoundationAuthPrefix()]
), function (Router $router) {
Routes\MediaRoutes::register($router);
});
}
}
65 changes: 65 additions & 0 deletions tests/MediaServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php namespace Arcanesoft\Media\Tests;

/**
* Class MediaServiceProviderTest
*
* @package Arcanesoft\Media\Tests
* @author ARCANEDEV <[email protected]>
*/
class MediaServiceProviderTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/** @var \Arcanesoft\Media\MediaServiceProvider */
protected $provider;

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
public function setUp()
{
parent::setUp();

$this->provider = $this->app->getProvider(\Arcanesoft\Media\MediaServiceProvider::class);
}

public function tearDown()
{
unset($this->provider);

parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
*/
/** @test */
public function it_can_be_instantiated()
{
$expectations = [
\Illuminate\Support\ServiceProvider::class,
\Arcanedev\Support\ServiceProvider::class,
\Arcanedev\Support\PackageServiceProvider::class,
\Arcanesoft\Core\Bases\PackageServiceProvider::class,
\Arcanesoft\Media\MediaServiceProvider::class,
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->provider);
}
}

/** @test */
public function it_can_provides()
{
$expected = [
//
];

$this->assertSame($expected, $this->provider->provides());
}
}
Loading

0 comments on commit a6447b4

Please sign in to comment.