Skip to content

Commit

Permalink
Updating random stuff (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Mar 10, 2017
1 parent 49b31d4 commit 96b827d
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 0 deletions.
16 changes: 16 additions & 0 deletions config/seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,20 @@
],
],

/* -----------------------------------------------------------------
| Widgets
| -----------------------------------------------------------------
*/
'widgets' => [
'footers' => [
'columns' => 2, // Supported: 1, 2, 4

'route' => [
'as' => 'public::seo.footers.',
'namespace' => 'Arcanesoft\\Seo\\Http\\Controllers\\Front',
'middleware' => ['public'],
],
],
],

];
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@php($columns = config('arcanesoft.seo.widgets.footers.columns', 1))

@include("seo::public._composers.widgets.footers.{$columns}-col-links")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@include('seo::public._composers.widgets.footers._links', ['items' => $seoFooters])
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="row">
@foreach($seoFooters->chunk(ceil($seoFooters->count() / 2)) as $items)
<div class="col-sm-6">
@include('seo::public._composers.widgets.footers._links', ['items' => $items])
</div>
@endforeach
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="row">
@foreach($seoFooters->chunk(ceil($seoFooters->count() / 4)) as $items)
<div class="col-sm-6 col-md-3">
@include('seo::public._composers.widgets.footers._links', ['items' => $items])
</div>
@endforeach
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ul class="footer-links-widget">
@foreach($items as $item)
<li>
{{ link_to_route('public::seo.footers.show', $item->name.' '.$item->localization, [$item->uri]) }}
</li>
@endforeach
</ul>
11 changes: 11 additions & 0 deletions resources/views/public/footer-page.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@extends('_templates.default.master')

@section('page-title')
{{ $footer->seo->title }}
@endsection

@section('content')
<div class="container">
{!! $footer->content !!}
</div>
@endsection
27 changes: 27 additions & 0 deletions src/Http/Controllers/Front/FootersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php namespace Arcanesoft\Seo\Http\Controllers\Front;

use App\Http\Controllers\Controller;
use Arcanesoft\Seo\Models\Footer;

/**
* Class FootersController
*
* @package Arcanesoft\Seo\Http\Controllers\Front
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class FootersController extends Controller
{
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
public function show(Footer $footer)
{
$footer->load(['seo']);

$this->setTitle($footer->seo->title);
$this->addBreadcrumb($footer->seo->title);

return $this->view('seo::public.footer-page', compact('footer'));
}
}
33 changes: 33 additions & 0 deletions src/Http/Routes/Front/FootersRoutes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php namespace Arcanesoft\Seo\Http\Routes\Front;

use Arcanedev\Support\Routing\RouteRegistrar;
use Arcanesoft\Seo\Models\Footer;

/**
* Class FootersRoutes
*
* @package Arcanesoft\Seo\Http\Routes\Front
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class FootersRoutes extends RouteRegistrar
{
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Define the routes for the application.
*/
public function map()
{
$this->bind('seo_footer_uri', function ($uri) {
return Footer::where('uri', $uri)
->where('locale', config('app.locale'))
->firstOrFail();
});

$this->group(config('arcanesoft.seo.widgets.footers.route', []), function () {
$this->get('{seo_footer_uri}.html', 'FootersController@show')->name('show');
});
}
}
10 changes: 10 additions & 0 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function map()
$this->adminGroup(function () {
$this->mapAdminRoutes();
});

$this->mapPublicRoutes();
}

/**
Expand All @@ -53,4 +55,12 @@ private function mapAdminRoutes()
Routes\Admin\SettingsRoutes::register();
});
}

/**
* Map the public routes.
*/
private function mapPublicRoutes()
{
Routes\Front\FootersRoutes::register();
}
}
31 changes: 31 additions & 0 deletions src/Providers/ViewComposerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php namespace Arcanesoft\Seo\Providers;

use Arcanedev\Support\Providers\ViewComposerServiceProvider as ServiceProvider;

use Arcanesoft\Seo\ViewComposers\Front\FooterWidgetComposer;

/**
* Class ViewComposerServiceProvider
*
* @package Arcanesoft\Seo\Providers
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class ViewComposerServiceProvider extends ServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* Register the composer classes.
*
* @var array
*/
protected $composerClasses = [
// Dashboard view composers


// Public view composers (Widgets)
FooterWidgetComposer::VIEW => FooterWidgetComposer::class,
];
}
1 change: 1 addition & 0 deletions src/SeoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function boot()
parent::boot();

$this->registerProvider(Providers\RouteServiceProvider::class);
$this->registerProvider(Providers\ViewComposerServiceProvider::class);

// Publishes
$this->publishConfig();
Expand Down
36 changes: 36 additions & 0 deletions src/ViewComposers/Front/FooterWidgetComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php namespace Arcanesoft\Seo\ViewComposers\Front;

use Arcanesoft\Seo\Models\Footer;
use Arcanesoft\Seo\ViewComposers\ViewComposer;
use Illuminate\Contracts\View\View;

/**
* Class FooterWidgetComposer
*
* @package Arcanesoft\Seo\ViewComposers\Front
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class FooterWidgetComposer extends ViewComposer
{
/* -----------------------------------------------------------------
| Constants
| -----------------------------------------------------------------
*/
const VIEW = 'seo::public._composers.widgets.footer-widget';

/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Compose the view.
*
* @param \Illuminate\Contracts\View\View $view
*/
public function compose(View $view)
{
$this->view = $view;

$this->view->with('seoFooters', Footer::all());
}
}
48 changes: 48 additions & 0 deletions src/ViewComposers/ViewComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php namespace Arcanesoft\Seo\ViewComposers;

use Closure;
use Illuminate\Support\Facades\Cache;

/**
* Class ViewComposer
*
* @package Arcanesoft\Seo\Bases
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class ViewComposer
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* The View instance.
*
* @var \Illuminate\Contracts\View\View
*/
protected $view;

/**
* Caching time.
*
* @var int
*/
protected $minutes = 5;

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Cache the results.
*
* @param string $name
* @param \Closure $callback
*
* @return mixed
*/
protected function cacheResults($name, Closure $callback)
{
return Cache::remember('cache::' . $name, $this->minutes, $callback);
}
}

0 comments on commit 96b827d

Please sign in to comment.