parent
f03862b523
commit
1a43060996
42 changed files with 1160 additions and 83 deletions
|
|
@ -35,7 +35,7 @@ class AdminUserController extends Controller
|
|||
//'values' => User::where('admin', 0)->get(),
|
||||
'values' => User::where('confirmation_code_remider', '!=', 2)->get(),
|
||||
];
|
||||
return view('admin.users', $data);
|
||||
return view('admin.user.index', $data);
|
||||
}
|
||||
|
||||
public function edit($user_id)
|
||||
|
|
@ -48,7 +48,7 @@ class AdminUserController extends Controller
|
|||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('admin.user_edit', $data);
|
||||
return view('admin.user.edit', $data);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
77
app/Http/Controllers/CountryController.php
Executable file
77
app/Http/Controllers/CountryController.php
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
|
||||
use App\Models\Country;
|
||||
use Input;
|
||||
|
||||
|
||||
class CountryController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'values' => Country::all(),
|
||||
];
|
||||
return view('admin.country.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
$model = new Country();
|
||||
$model->active = true;
|
||||
}else{
|
||||
$model = Country::findOrFail($id);
|
||||
}
|
||||
$data = [
|
||||
'country' => $model,
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
|
||||
];
|
||||
return view('admin.country.edit', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Input::all();
|
||||
if(!isset($data['attr'])){
|
||||
$data['attr'] = [];
|
||||
}
|
||||
if($data['id'] === "new"){
|
||||
$model = Country::create([
|
||||
/* 'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
*/
|
||||
]);
|
||||
}else{
|
||||
$model = Country::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_country_edit', $model->id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ class LeadController extends Controller
|
|||
$data = [
|
||||
'values' => User::where('admin', '=', 0)->where('confirmation_code_remider', '!=', 2)->get(),
|
||||
];
|
||||
return view('admin.leads', $data);
|
||||
return view('admin.lead.index', $data);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class LeadController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if($id == "new"){
|
||||
if($id === "new"){
|
||||
$user = new User();
|
||||
$user->account = new UserAccount();
|
||||
$user->account->same_as_billing = 1;
|
||||
|
|
@ -61,7 +61,7 @@ class LeadController extends Controller
|
|||
'user' => $user,
|
||||
'can_change_mail' => true,
|
||||
];
|
||||
return view('admin.lead_edit', $data);
|
||||
return view('admin.lead.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +72,7 @@ class LeadController extends Controller
|
|||
{
|
||||
|
||||
$data = Input::all();
|
||||
if ($data['user_id'] == "new" || $data['user_id'] == 0) {
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
|
|
@ -108,7 +108,7 @@ class LeadController extends Controller
|
|||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
|
||||
if ($data['user_id'] == "new" || $data['user_id'] == 0) {
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user_id = "new";
|
||||
}else{
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
|
|
@ -117,7 +117,7 @@ class LeadController extends Controller
|
|||
return redirect(route('admin_lead_edit', [$user_id]))->withErrors($validator)->withInput(Input::all());
|
||||
}else{
|
||||
|
||||
if ($data['user_id'] == "new" || $data['user_id'] == 0) {
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user = new User();
|
||||
$user->id = "new";
|
||||
$user->account = new UserAccount();
|
||||
|
|
@ -129,8 +129,12 @@ class LeadController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$user->m_level = isset($data['m_level']) ? $data['m_level'] : NULL;
|
||||
$user->save();
|
||||
|
||||
$this->userRepo->update($data);
|
||||
|
||||
|
||||
if(isset($data['contact_verify'])){
|
||||
|
||||
$user = $this->userRepo->getModel();
|
||||
|
|
@ -150,10 +154,13 @@ class LeadController extends Controller
|
|||
|
||||
|
||||
Mail::to($user->email)->send(new MailVerifyContact($confirmation_code, $user));
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_leads'));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_leads'));
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ProductController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'values' => Product::all(),
|
||||
'values' => Product::orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get(),
|
||||
];
|
||||
return view('admin.product.index', $data);
|
||||
}
|
||||
|
|
@ -78,6 +78,17 @@ class ProductController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function copy($id){
|
||||
$model = Product::findOrFail($id);
|
||||
|
||||
$product = $this->productRepo->copy($model);
|
||||
|
||||
|
||||
|
||||
\Session()->flash('alert-success', 'Eintrag kopiert');
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$model = Product::findOrFail($id);
|
||||
$model->delete();
|
||||
|
|
|
|||
84
app/Http/Controllers/UserLevelController.php
Executable file
84
app/Http/Controllers/UserLevelController.php
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\ProductAttribute;
|
||||
use App\Models\UserLevel;
|
||||
use Input;
|
||||
|
||||
|
||||
class UserLevelController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => UserLevel::all(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.level.index', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = UserLevel::create([
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'margin' => $data['margin'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = UserLevel::find($data['id']);
|
||||
$model->name = $data['name'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->margin = $data['margin'];
|
||||
$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_levels'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*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'));
|
||||
}
|
||||
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
@ -43,6 +43,8 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereHeadline($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereHeadlineImageId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransHeadline($value)
|
||||
* @property-read \App\Models\IqImage|null $iq_image
|
||||
* @property-read int|null $product_categories_count
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
|
@ -93,7 +95,7 @@ class Category extends Model
|
|||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
if ($lang == 'de') {
|
||||
if ($lang === 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
|
|
|
|||
|
|
@ -30,37 +30,80 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country query()
|
||||
* @property int|null $active
|
||||
* @property array|null $trans
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTrans($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereUpdatedAt($value)
|
||||
* @property string|null $trans_name
|
||||
* @property array|null $attr
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereAttr($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTransName($value)
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
protected $table = 'countries';
|
||||
|
||||
protected $casts = ['trans_name' => 'array', 'attr' => 'array'];
|
||||
|
||||
public function getLocated($lang = 'de'){
|
||||
protected $fillable = [
|
||||
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru', 'active', 'trans_name', 'attr'
|
||||
];
|
||||
|
||||
$lang = \App::getLocale();
|
||||
public function getLocated($lang = false){
|
||||
|
||||
if($lang == 'de'){
|
||||
if(!$lang){
|
||||
$lang = \App::getLocale();
|
||||
|
||||
}
|
||||
if($lang === 'de'){
|
||||
return $this->de;
|
||||
}
|
||||
if($lang == 'en'){
|
||||
if($lang === 'en'){
|
||||
return $this->en;
|
||||
}
|
||||
if($lang == 'es'){
|
||||
if($lang === 'es'){
|
||||
return $this->es;
|
||||
}
|
||||
if($lang == 'fr'){
|
||||
if($lang === 'fr'){
|
||||
return $this->fr;
|
||||
}
|
||||
if($lang == 'it'){
|
||||
if($lang === 'it'){
|
||||
return $this->it;
|
||||
}
|
||||
if($lang == 'ru'){
|
||||
if($lang === 'ru'){
|
||||
return $this->ru;
|
||||
}
|
||||
|
||||
//search by trans
|
||||
|
||||
if($val = $this->getTrans('name', $lang)){
|
||||
return $val;
|
||||
}
|
||||
return $this->de;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getAttrByKey($key)
|
||||
{
|
||||
$name = 'attr';
|
||||
if (!empty($this->{$name}[$key])) {
|
||||
return $this->{$name}[$key];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getCountryIdByCode($code){
|
||||
if($code == null){
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqImage wherePos($value)
|
||||
*/
|
||||
class IqImage extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,33 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\IqSite
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $slug
|
||||
* @property string|null $headline
|
||||
* @property string|null $copy
|
||||
* @property array|null $products
|
||||
* @property array|null $set_products
|
||||
* @property int|null $iq_image_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\IqImage|null $iq_image
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereCopy($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereHeadline($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereIqImageId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereProducts($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereSetProducts($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class IqSite extends Model
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereAction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWeight($value)
|
||||
* @property int|null $points
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $imagesActive
|
||||
* @property-read int|null $images_active_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePoints($value)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -117,6 +121,7 @@ class Product extends Model
|
|||
'price_ek',
|
||||
'tax',
|
||||
'price_old',
|
||||
'points',
|
||||
'weight',
|
||||
'contents',
|
||||
'number',
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage wherePos($value)
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedShipping()
|
||||
{
|
||||
if (\App::getLocale() == "en") {
|
||||
if (\App::getLocale() === "en") {
|
||||
return number_format($this->attributes['shipping'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['shipping'], 2, ',', '.');
|
||||
|
|
@ -118,7 +118,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedTotalShipping()
|
||||
{
|
||||
if (\App::getLocale() == "en") {
|
||||
if (\App::getLocale() === "en") {
|
||||
return number_format($this->attributes['total_shipping'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['total_shipping'], 2, ',', '.');
|
||||
|
|
@ -127,7 +127,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
if (\App::getLocale() == "en") {
|
||||
if (\App::getLocale() === "en") {
|
||||
return number_format($this->attributes['price'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price'], 2, ',', '.');
|
||||
|
|
|
|||
|
|
@ -105,11 +105,9 @@ use Carbon\Carbon;
|
|||
class UserAccount extends Model
|
||||
{
|
||||
protected $table = 'user_accounts';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'company', 'salutation', 'first_name', 'last_name', 'address', 'address_2', 'zipcode', 'city', 'country_id', 'pre_phone_id', 'phone', 'pre_mobil_id', 'mobil',
|
||||
'tax_number', 'tax_identification_number', 'same_as_billing',
|
||||
'm_account', 'm_salutation', 'm_first_name', 'm_last_name', 'm_notes', 'company', 'salutation', 'first_name', 'last_name', 'address', 'address_2', 'zipcode', 'city', 'country_id', 'pre_phone_id', 'phone', 'pre_mobil_id', 'mobil',
|
||||
'tax_number', 'tax_identification_number', 'taxable_sales', 'same_as_billing',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_pre_phone_id', 'shipping_phone',
|
||||
'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram'
|
||||
];
|
||||
|
|
@ -166,6 +164,22 @@ class UserAccount extends Model
|
|||
}
|
||||
|
||||
|
||||
public function getCountryAttrAs($attr, $as = false){
|
||||
if($this->country){
|
||||
$val = $this->country->getAttrByKey($attr);
|
||||
|
||||
if($val){
|
||||
if($as){
|
||||
return $as;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
79
app/Models/UserLevel.php
Normal file
79
app/Models/UserLevel.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserLevel extends Model
|
||||
{
|
||||
protected $table = 'user_levels';
|
||||
|
||||
protected $casts = ['trans_name' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'margin', 'pos', 'active',
|
||||
];
|
||||
|
||||
|
||||
/* public function childrens()
|
||||
{
|
||||
return $this->hasMany('App\Models\Attribute', 'parent_id', 'id');
|
||||
}
|
||||
*/
|
||||
|
||||
public function setPosAttribute($value){
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setMarginAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['margin'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getFormattedMargin()
|
||||
{
|
||||
if(!isset($this->attributes['margin'])){
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() === "en"){
|
||||
return number_format($this->attributes['margin'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['margin'], 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
if ($lang === 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
if (!$trans || $trans == '') {
|
||||
return $this->{$key};
|
||||
}
|
||||
return $trans;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
}
|
||||
|
||||
public function getTranNames()
|
||||
{
|
||||
$ret = "";
|
||||
foreach ((array) $this->trans_name as $value){
|
||||
$ret .= $value.', ';
|
||||
}
|
||||
return rtrim($ret, ', ');
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ namespace App\Repositories;
|
|||
use App\Models\Product;
|
||||
use App\Models\ProductAttribute;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ProductImage;
|
||||
|
||||
class ProductRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -84,6 +85,57 @@ class ProductRepository extends BaseRepository {
|
|||
}
|
||||
|
||||
|
||||
public function copy($model)
|
||||
{
|
||||
$this->model = $model->replicate();
|
||||
$this->model->name = "Kopie: ".$this->model->name;
|
||||
$this->model->save();
|
||||
|
||||
//categories
|
||||
foreach ($model->categories as $category){
|
||||
ProductCategory::create([
|
||||
'product_id' => $this->model->id,
|
||||
'category_id' => $category->category_id,
|
||||
]);
|
||||
}
|
||||
|
||||
//attributes
|
||||
foreach ($model->attributes as $attribute){
|
||||
ProductAttribute::create([
|
||||
'product_id' => $this->model->id,
|
||||
'attribute_id' => $attribute->attribute_id,
|
||||
]);
|
||||
}
|
||||
|
||||
//images
|
||||
foreach ($model->images as $image){
|
||||
$name = \App\Services\Slim::sanitizeFileName($image->original_name);
|
||||
$name = uniqid() . '_' . $name;
|
||||
|
||||
//copy
|
||||
$data = \Storage::disk('public')->copy(
|
||||
'images/product/'.$image->product_id.'/'.$image->filename,
|
||||
'images/product/'.$this->model->id.'/'.$name
|
||||
);
|
||||
|
||||
|
||||
ProductImage::create([
|
||||
'product_id' => $this->model->id,
|
||||
'filename' => $name,
|
||||
'original_name' => $image->original_name,
|
||||
'ext' => $image->ext,
|
||||
'mine' => $image->mine,
|
||||
'size' => $image->size
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function delete()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class UserRepository extends BaseRepository {
|
|||
public function update($data)
|
||||
{
|
||||
|
||||
if($data['user_id'] == "new" || $data['user_id'] == 0){
|
||||
if($data['user_id'] === "new" || $data['user_id'] == 0){
|
||||
|
||||
$this->model = User::create([
|
||||
'email' => $data['email'],
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Models\Category;
|
|||
use App\Models\Country;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\UserLevel;
|
||||
|
||||
class HTMLHelper
|
||||
{
|
||||
|
|
@ -156,6 +157,19 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getUserLevelOptions($id = false, $all = true){
|
||||
$values = UserLevel::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getCompanyOptions($company){
|
||||
$options = array(1 => __('business'), 0 => __('private'), );
|
||||
|
|
@ -258,6 +272,18 @@ class HTMLHelper
|
|||
return (!empty($values[$id]) ? $values[$id] : '');
|
||||
}
|
||||
|
||||
public static function getTaxSaleOptions($id){
|
||||
$values = array('1' => __('taxable_sales_1'), '2' => __('taxable_sales_2'));
|
||||
$ret = "";
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
foreach ($values as $key => $value){
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/*public static function getIndustrySectorsWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = IndustrySector::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue