Commit ba8d0a92 authored by Nicolas Widart's avatar Nicolas Widart

Merge commit '7f79ef73'

* commit '7f79ef73':
  Squashed 'Modules/Core/' changes from e713728..5720517
parents a75693f1 7f79ef73
<?php namespace Modules\Core\Composers;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\App;
class LocaleComposer
{
public function compose(View $view)
{
$view->with('currentLocale', App::getLocale());
}
}
...@@ -13,9 +13,9 @@ abstract class BasePublicController ...@@ -13,9 +13,9 @@ abstract class BasePublicController
*/ */
private $setting; private $setting;
public function __construct(Setting $setting) public function __construct()
{ {
$this->setting = $setting; $this->setting = app('setting.settings');
$this->theme = $this->setting->get('core::template'); $this->theme = $this->setting->get('core::template');
} }
} }
...@@ -39,4 +39,18 @@ interface BaseRepository ...@@ -39,4 +39,18 @@ interface BaseRepository
* @return mixed * @return mixed
*/ */
public function destroy($model); public function destroy($model);
/**
* Return resources translated in the given language
* @param $lang
* @return object
*/
public function allTranslatedIn($lang);
/**
* Find a resource by the given slug
* @param int $slug
* @return object
*/
public function findBySlug($slug);
} }
...@@ -60,4 +60,30 @@ abstract class EloquentBaseRepository implements BaseRepository ...@@ -60,4 +60,30 @@ abstract class EloquentBaseRepository implements BaseRepository
{ {
return $model->delete(); return $model->delete();
} }
/**
* Return all categories in the given language
* @param $lang
* @return mixed
*/
public function allTranslatedIn($lang)
{
return $this->model->whereHas('translations', function($q) use($lang)
{
$q->where('locale', "$lang");
})->orderBy('created_at', 'DESC')->get();
}
/**
* Find a resource by the given slug
* @param int $slug
* @return object
*/
public function findBySlug($slug)
{
return $this->model->whereHas('translations', function($q) use($slug)
{
$q->where('slug', "$slug");
})->first();
}
} }
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
View::creator('core::partials.sidebar-nav', 'Modules\Core\Composers\SidebarViewCreator'); View::creator('core::partials.sidebar-nav', 'Modules\Core\Composers\SidebarViewCreator');
View::composer('core::layouts.master', 'Modules\Core\Composers\MasterViewComposer'); View::composer('core::layouts.master', 'Modules\Core\Composers\MasterViewComposer');
View::composer('core::fields.select-theme', 'Modules\Core\Composers\ThemeComposer'); View::composer('core::fields.select-theme', 'Modules\Core\Composers\ThemeComposer');
View::composer('*', 'Modules\Core\Composers\LocaleComposer');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment