17 Nov - Static Sites to laravel
This commit is contained in:
parent
610aa1e202
commit
5ff57a21a7
3661 changed files with 569001 additions and 771 deletions
88
app/Http/Controllers/AttributeController.php
Executable file
88
app/Http/Controllers/AttributeController.php
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\ProductAttribute;
|
||||
use Input;
|
||||
|
||||
|
||||
class AttributeController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => Attribute::all(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.attribute.index', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = Attribute::create([
|
||||
'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = Attribute::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
|
||||
if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
if(count($trans)){
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
|
||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(Attribute::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_industry_sectors'));
|
||||
}
|
||||
*/
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
|
||||
}
|
||||
85
app/Http/Controllers/CategoryController.php
Executable file
85
app/Http/Controllers/CategoryController.php
Executable file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\ProductCategory;
|
||||
use Input;
|
||||
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => Category::all(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.category.index', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = Category::create([
|
||||
'parent_id' => isset($data['parent_id']) ? $data['parent_id'] : null,
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = Category::find($data['id']);
|
||||
$model->parent_id = isset($data['parent_id']) ? $data['parent_id'] : null;
|
||||
$model->name = $data['name'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
|
||||
if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
if(count($trans)){
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_categories'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
|
||||
if(ProductCategory::where('category_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Produkt-Kategorie verwendet');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
if(Category::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Haup-Kategorie verwendet');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
$model = Category::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
|
||||
}
|
||||
106
app/Http/Controllers/ImportProductController.php
Executable file
106
app/Http/Controllers/ImportProductController.php
Executable file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductImage;
|
||||
use App\Repositories\ProductRepository;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
class ImportProductController extends Controller
|
||||
{
|
||||
protected $productRepo;
|
||||
|
||||
public function __construct(ProductRepository $productRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->productRepo = $productRepo;
|
||||
|
||||
}
|
||||
|
||||
public function import(){
|
||||
|
||||
$path = app_path().'/../_static/products/';
|
||||
|
||||
include($path.'_all_products.php');
|
||||
|
||||
$slugs = array();
|
||||
|
||||
foreach ($get_products as $c_id => $values){
|
||||
|
||||
foreach ($values as $val){
|
||||
if(in_array($val['slug'], $slugs)){
|
||||
continue;
|
||||
}
|
||||
$slugs[] = $val['slug'];
|
||||
|
||||
include($path.$val['slug'].'.php');
|
||||
|
||||
$data = [
|
||||
'id' => 'new',
|
||||
'name' => $val['name'],
|
||||
'title' => '',
|
||||
'copy' => $copy,
|
||||
'price' => $price,
|
||||
'price_ek' => 0,
|
||||
'tax' => 19,
|
||||
'price_old' => null,
|
||||
'contents' => $content,
|
||||
'number' => $item_no,
|
||||
'icons' => $icons,
|
||||
'description' => $description,
|
||||
'usage' => $usage,
|
||||
'ingredients' => $ingredients,
|
||||
'pos' => null,
|
||||
'amount' => 0,
|
||||
'active' => 1,
|
||||
'categories' => array($c_id),
|
||||
];
|
||||
|
||||
|
||||
$product = $this->productRepo->update($data);
|
||||
//images
|
||||
foreach($images as $image){
|
||||
$i_path = storage_path().'/'.'app'.'/products/' .$val['slug'].'/'.$image['image'];
|
||||
$mine = \File::mimeType($i_path);
|
||||
$ext = \File::extension($i_path);
|
||||
$size = \File::size($i_path);
|
||||
$original_name = $image['image'];
|
||||
|
||||
$name = \App\Services\Slim::sanitizeFileName($image['image']);
|
||||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$img = \Image::make($i_path);
|
||||
$img->resize(600, 800, function ($c) {
|
||||
// $c->aspectRatio();
|
||||
$c->upsize();
|
||||
});
|
||||
//
|
||||
\Storage::put('/public/images/product/'.$product->id.'/'.$name, (string) $img->encode());
|
||||
|
||||
|
||||
ProductImage::create([
|
||||
'product_id' => $product->id,
|
||||
'filename' => $name,
|
||||
'original_name' => $original_name,
|
||||
'ext' => $ext,
|
||||
'mine' => $mine,
|
||||
'size' => $size
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
die("okay");
|
||||
//array('slug' => 'aloe-vera-gel99', 'name' => 'Aloe Vera Gel 99%', 'first' => 'aloe-vera-gel99-1.jpg', 'hover' => 'aloe-vera-gel99-2.jpg'),
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
166
app/Http/Controllers/ProductController.php
Executable file
166
app/Http/Controllers/ProductController.php
Executable file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductImage;
|
||||
use App\Repositories\ProductRepository;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
protected $productRepo;
|
||||
|
||||
public function __construct(ProductRepository $productRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->productRepo = $productRepo;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => Product::all(),
|
||||
];
|
||||
return view('admin.product.index', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id == "new"){
|
||||
$model = new Product();
|
||||
$model->active = true;
|
||||
}else{
|
||||
$model = Product::findOrFail($id);
|
||||
}
|
||||
$data = [
|
||||
'product' => $model,
|
||||
];
|
||||
return view('admin.product.edit', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Input::all();
|
||||
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
);
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if($data['id'] == "new"){
|
||||
$model = new Product();
|
||||
}else{
|
||||
$model = Product::findOrFail($data['id']);
|
||||
}
|
||||
$data = [
|
||||
'product' => $model,
|
||||
];
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
return view('admin.product.edit', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$product = $this->productRepo->update(Input::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_show'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$model = Product::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function uploadImage(){
|
||||
|
||||
$product_id = Input::get('product_id');
|
||||
$product = Product::findOrFail($product_id);
|
||||
|
||||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
$ext = $file_ex[$image['output']['type']];
|
||||
// Original file name
|
||||
$name = $image['output']['name'];
|
||||
$name = \App\Services\Slim::sanitizeFileName($name);
|
||||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
'images/product/'.$product->id.'/'.$name,
|
||||
$data
|
||||
);
|
||||
|
||||
ProductImage::create([
|
||||
'product_id' => $product->id,
|
||||
'filename' => $name,
|
||||
'original_name' => $image['output']['name'],
|
||||
'ext' => $ext,
|
||||
'mine' => $image['output']['type'],
|
||||
'size' => $image['input']['size']
|
||||
]);
|
||||
|
||||
|
||||
\Session()->flash('alert-success', "Datei hochgeladen");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
\Session()->flash('alert-danger', "Datei leer");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Fehler".$e);
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteImage($image_id, $product_id){
|
||||
|
||||
$product = Product::findOrFail($product_id);
|
||||
$product_image = ProductImage::findOrFail($image_id);
|
||||
|
||||
if($product_image->product_id == $product->id){
|
||||
$file = 'images/product/'.$product->id.'/'.$product_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
|
||||
$product_image->delete();
|
||||
|
||||
\Session()->flash('alert-success', "Datei gelöscht");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', "Datei nicht gefunden");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class TranslationController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
return redirect('admin/translate/edit/de');
|
||||
return redirect('admin/translate/all/edit/de');
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class TranslationController extends Controller
|
|||
$jsonData = json_encode($ret, TRUE);
|
||||
file_put_contents($file, $jsonData);
|
||||
return redirect()
|
||||
->route('admin_translate_edit', [$language])
|
||||
->route('admin_translate_all_edit', [$language])
|
||||
->with('message', 'Translation added successfully');
|
||||
}
|
||||
|
||||
|
|
|
|||
288
app/Http/Controllers/TranslationFileController.php
Executable file
288
app/Http/Controllers/TranslationFileController.php
Executable file
|
|
@ -0,0 +1,288 @@
|
|||
<?php
|
||||
|
||||
//use Input;
|
||||
//use Request;
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App;
|
||||
use File;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Requests\TranslationRequest;
|
||||
|
||||
|
||||
|
||||
|
||||
class TranslationFileController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Translator
|
||||
*
|
||||
* @var \Illuminate\Translation\Translator
|
||||
*/
|
||||
protected $translator;
|
||||
/**
|
||||
* Translation loader
|
||||
*
|
||||
* @var \Illuminate\Translation\LoaderInterface
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* @var \League\Flysystem\Adapter\Local
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $languagesPath;
|
||||
|
||||
protected $languageRead;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
$this->translator = App::make('translator');
|
||||
$this->loader = Lang::getLoader();
|
||||
$this->languagesPath = App::langPath();
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$language = App::getLocale();
|
||||
$langsource = 'de';
|
||||
$this->languageRead = $language;
|
||||
$langs = array_keys(config('localization.supportedLocales'));
|
||||
$files = $this->files();
|
||||
$translations = null;
|
||||
$edit = false;
|
||||
$show = 'all';
|
||||
return view('translation.index_file', compact('files', 'translations', 'language', 'langsource', 'langs', 'edit', 'show'));
|
||||
|
||||
//return view('admin.transitions', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display edit form page
|
||||
*
|
||||
* @param string $language
|
||||
* @param string $file
|
||||
* @param string|null $namespace
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($file, $language = 'en', $langsource = 'de', $show = 'all')
|
||||
{
|
||||
$this->languageRead = $language;
|
||||
$langs = array_keys(config('localization.supportedLocales'));
|
||||
$files = $this->files();
|
||||
$translations = $this->translations($file, $langsource);
|
||||
$prefix = $this->groupName($file);
|
||||
$langsource = $langsource;
|
||||
$edit = $file;
|
||||
$show = $show;
|
||||
|
||||
return view('translation.index_file', compact('files', 'language', 'langsource', 'file', 'translations', 'prefix', 'langs', 'edit', 'show'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save translation file
|
||||
*
|
||||
* @param \GeniusTS\TranslationManager\Requests\TranslationRequest $request
|
||||
* @param string $language
|
||||
* @param string $file
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(TranslationRequest $request, $file, $language, $langsource, $show)
|
||||
{
|
||||
$keys = array_keys($this->translations($file));
|
||||
|
||||
$this->exportFile($request->only($keys), $file, $language);
|
||||
|
||||
return redirect()
|
||||
->route('admin_translate_file_edit', [$file, $language, $langsource, $show])
|
||||
->with('message', 'Translation added successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a translation file
|
||||
*
|
||||
* @param array $translation
|
||||
* @param $filename
|
||||
* @param $language
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exportFile($translation, $filename, $language)
|
||||
{
|
||||
$path = "{$this->languagesPath}{$this->directory_separator}{$language}{$this->directory_separator}{$filename}.php";
|
||||
|
||||
$this->backup($path, $language, $filename);
|
||||
|
||||
$content = "<?php \n\n return " . var_export($translation, true) . ";";
|
||||
|
||||
return (bool) file_put_contents($path, $content);
|
||||
|
||||
//return (bool) $this->filesystem->write($path, $content, new Config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup the existing translation files
|
||||
*/
|
||||
private function backup($path, $language, $filename)
|
||||
{
|
||||
if(!File::exists($path)){
|
||||
return;
|
||||
}
|
||||
if (!File::exists(storage_path('language/'.time().'/'.$language))) {
|
||||
File::makeDirectory(storage_path('language/'.time().'/'.$language), 0755, true);
|
||||
}
|
||||
|
||||
return File::copy($path, storage_path('language/'.time().'/'.$language.'/'.$filename.'.php'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the translation of a group and name space
|
||||
*
|
||||
* @param string $file
|
||||
* @param string|null $namespace
|
||||
* @param string|null $language
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function translations($file, $language = null)
|
||||
{
|
||||
$group = $this->groupName($file);
|
||||
$key = $group;
|
||||
|
||||
return $this->translator->trans($key, [], $language ?: $this->defaultLanguage());
|
||||
}
|
||||
|
||||
public function files($lang = false)
|
||||
{
|
||||
$path = $this->namespacePath($this->languagesPath, $lang);
|
||||
|
||||
$content = $this->pathContent($path);
|
||||
|
||||
return $content
|
||||
->map(function ($file) use ($path) {
|
||||
$path = ltrim($path . DIRECTORY_SEPARATOR, '/');
|
||||
//read file empty entries
|
||||
$count = $this->countEmptyEntries(Str::replaceLast($path, '', $file));
|
||||
//var_dump($translations);
|
||||
return array(ltrim($this->groupName(Str::replaceLast($path, '', $file)), '/') => ltrim($this->groupName(Str::replaceLast($path, '', $file)), '/')." (".$count.")");
|
||||
})
|
||||
->flatten();
|
||||
}
|
||||
|
||||
public function countEmptyEntries($file){
|
||||
|
||||
$translation = $this->translations($file);
|
||||
$group = $this->groupName($file);
|
||||
$entries = 0;
|
||||
$count = 0;
|
||||
foreach ($translation as $key => $value)
|
||||
{
|
||||
$this->searchForEmpty($key, $value, null, $count, $entries, $group);
|
||||
}
|
||||
return $entries."/".$count;
|
||||
}
|
||||
|
||||
protected function searchForEmpty($key, $value, $prefix, &$count, &$entries, $group)
|
||||
{
|
||||
$prefix = $prefix ? "{$prefix}.{$key}" : $group.".".$key;
|
||||
if (is_array($value))
|
||||
{
|
||||
foreach ($value as $subKey => $subValue)
|
||||
{
|
||||
$this->searchForEmpty($subKey, $subValue, $prefix, $count,$entries, $group);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Lang::has($prefix, $this->languageRead, false)){
|
||||
$count++;
|
||||
}
|
||||
|
||||
if(Lang::has($prefix, 'de', false)){
|
||||
$entries ++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default language
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function defaultLanguage()
|
||||
{
|
||||
return config('app.fallback_locale', 'de');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the group name from a filename
|
||||
*
|
||||
* @param $filename
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function groupName($filename)
|
||||
{
|
||||
return preg_replace('/\.php$/', '', $filename);
|
||||
}
|
||||
/**
|
||||
* Get default language
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $language
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function namespacePath($path, $language = null)
|
||||
{
|
||||
return "{$path}{$this->directory_separator}" . ($language ?: $this->defaultLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
* List content of a path
|
||||
*
|
||||
* @param null $path
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected function pathContent($path = null, $recursive = false)
|
||||
{
|
||||
|
||||
//var_dump($this->filesystem->listContents($path, $recursive));
|
||||
//return new Collection(($this->filesystem->listContents($path, $recursive)));
|
||||
return new Collection(File::files($path));
|
||||
}
|
||||
|
||||
}
|
||||
86
app/Http/Controllers/Web/SiteController.php
Executable file
86
app/Http/Controllers/Web/SiteController.php
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use Carbon\Carbon;
|
||||
use Request;
|
||||
use Input;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('web.index');
|
||||
}
|
||||
|
||||
public function site($site, $subsite = false, $product_slug = false)
|
||||
{
|
||||
|
||||
if($product_slug){
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
$product = Product::where('slug', $product_slug)->where('active', true)->first();
|
||||
if ($category && $product) {
|
||||
|
||||
|
||||
$data = [
|
||||
'subsite' => $subsite,
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'product' => $product,
|
||||
'p_count' => Product::where('active', true)->count(),
|
||||
|
||||
];
|
||||
return view('web.templates.produkte-show', $data);
|
||||
}
|
||||
}
|
||||
|
||||
if($site == 'produkte'){
|
||||
|
||||
if($subsite || $subsite != 'alle-produkte') {
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
if ($category) {
|
||||
$data = [
|
||||
'subsite' => $subsite,
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'products' => Product::whereHas('categories', function ($query) use ($category) {
|
||||
$query->where('category_id', '=', $category->id);
|
||||
|
||||
})->where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'p_count' => Product::where('active', true)->count(),
|
||||
|
||||
];
|
||||
return view('web.templates.' . $site, $data);
|
||||
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'subsite' => 'alle-produkte',
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'products' => Product::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'p_count' => Product::where('active', true)->count(),
|
||||
];
|
||||
return view('web.templates.'.$site, $data);
|
||||
}
|
||||
|
||||
if($subsite){
|
||||
return view('web.templates.'.$subsite);
|
||||
}
|
||||
|
||||
return view('web.templates.'.$site);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue