diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php new file mode 100644 index 0000000..7ff8946 --- /dev/null +++ b/app/Http/Controllers/OrderController.php @@ -0,0 +1,34 @@ +$o]); + } + + public function product_info(Product $o) + { + Theme::set('metronic-fe'); + + return view('widgets.product_description',['o'=>$o]); + } + + public function submit(Request $request) + { + } +} \ No newline at end of file diff --git a/app/Models/Product.php b/app/Models/Product.php index 595a809..7fa68fc 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Auth; class Product extends Model { @@ -19,19 +20,56 @@ class Product extends Model return $this->hasMany(Service::class); } + public function getCategoryAttribute() + { + return $this->prod_plugin_file; + } + + public function getDescriptionAttribute() + { + // @todo If the user has selected a specific language. + return $this->description($this->getDefaultLanguage()); + } + + public function getNameAttribute() + { + return $this->name(Auth::user()->language); + } + public function getProductIdAttribute() { return sprintf('#%04s',$this->id); } + public function scopeActive() + { + return $this->where('active',TRUE); + } + + public function description(Language $lo=NULL) + { + if (is_null($lo)) + $lo = $this->getDefaultLanguage(); + + return $this->descriptions->where('language_id',$lo->id)->first()->description_short; + } + + private function getDefaultLanguage() + { + return config('SITE_SETUP')->language; + } + /** - * Get the language name + * Get the product name * * @param Language $lo * @return string Product Name */ - public function name(Language $lo) + public function name(Language $lo=NULL) { + if (is_null($lo)) + $lo = $this->getDefaultLanguage(); + return $this->descriptions->where('language_id',$lo->id)->first()->name; } } \ No newline at end of file diff --git a/app/Models/Service.php b/app/Models/Service.php index 080dd09..aa32ce3 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -77,7 +77,7 @@ class Service extends Model public function getCategoryAttribute() { - return $this->product->prod_plugin_file; + return $this->product->category; } public function getNameAttribute() diff --git a/app/User.php b/app/User.php index 44397df..3fe88b4 100644 --- a/app/User.php +++ b/app/User.php @@ -95,6 +95,8 @@ class User extends Authenticatable return $this->hasMany(static::class,'parent_id','id'); } + /** Attributes **/ + public function getActiveDisplayAttribute($value) { return sprintf('%s',$this->active ? 'primary' : 'danger',$this->active ? 'Active' : 'Inactive'); @@ -110,24 +112,6 @@ class User extends Authenticatable return sprintf('%s %s',$this->firstname,$this->lastname); } - public function getSurFirstNameAttribute() - { - return sprintf('%s, %s',$this->lastname,$this->firstname); - } - - /** - * Return a Carbon Date if it has a value. - * - * @param $value - * @return \Leenooks\Carbon - * @todo This attribute is not in the schema - */ - public function getLastAccessAttribute($value) - { - if (! is_null($value)) - return new Carbon($value); - } - public function getInvoicesDueAttribute() { return $this->invoices @@ -144,6 +128,28 @@ class User extends Authenticatable return config('SITE_SETUP')->language; } + /** + * Return a Carbon Date if it has a value. + * + * @param $value + * @return \Leenooks\Carbon + * @todo This attribute is not in the schema + */ + public function getLastAccessAttribute($value) + { + if (! is_null($value)) + return new Carbon($value); + } + + /** + * @deprecated Use static::getFullNameAttribute() + * @return mixed + */ + public function getNameAttribute() + { + return $this->full_name; + } + public function getPaymentHistoryAttribute() { return $this->payments @@ -157,20 +163,16 @@ class User extends Authenticatable ->where('active',TRUE); } - /** - * @deprecated Use static::getFullNameAttribute() - * @return mixed - */ - public function getNameAttribute() - { - return $this->full_name; - } - public function getServicesCountHtmlAttribute() { return sprintf('%s /%s',$this->services->where('active',TRUE)->count(),$this->services->count()); } + public function getSurFirstNameAttribute() + { + return sprintf('%s, %s',$this->lastname,$this->firstname); + } + public function getSwitchUrlAttribute() { return sprintf('',$this->id); @@ -186,41 +188,14 @@ class User extends Authenticatable return sprintf('%s',$this->id,$this->user_id); } + /** Scopes **/ + public function scopeActive() { return $this->where('active',TRUE); } - public function isAdmin($id) - { - return $id AND in_array($this->role(),['wholesaler','reseller']) AND in_array($id,$this->all_accounts()->pluck('id')->toArray()); - } - - public function sendPasswordResetNotification($token) - { - $this->notify(new ResetPasswordNotification($token)); - } - - // List all the agents, including agents of agents - public function all_agents($level=0) - { - $result = collect(); - - foreach ($this->agents as $o) - { - if (! $o->active OR ! $o->agents->count()) - continue; - - $o->level = $level; - - $result->push($o); - - // Include agents of agents - $result->push($o->all_agents($level+1)); - } - - return $result->flatten(); - } + /** Functions */ public function all_accounts() { @@ -253,6 +228,49 @@ class User extends Authenticatable return $result->flatten(); } + + // List all the agents, including agents of agents + public function all_agents($level=0) + { + $result = collect(); + + foreach ($this->agents as $o) + { + if (! $o->active OR ! $o->agents->count()) + continue; + + $o->level = $level; + + $result->push($o); + + // Include agents of agents + $result->push($o->all_agents($level+1)); + } + + return $result->flatten(); + } + + /** + * Determine if the user is an admin of the account with $id + * + * @param $id + * @return bool + */ + public function isAdmin($id) + { + return $id AND $this->isReseller() AND in_array($id,$this->all_accounts()->pluck('id')->toArray()); + } + + /** + * Determine if the logged in user is a reseller or wholesaler + * + * @return bool + */ + public function isReseller() + { + return in_array($this->role(),['wholesaler','reseller']); + } + public function role() { // If I have agents and no parent, I am the wholesaler @@ -267,4 +285,8 @@ class User extends Authenticatable elseif (! $this->all_agents()->count() AND ! $this->all_clients()->count()) return 'customer'; } + public function sendPasswordResetNotification($token) + { + $this->notify(new ResetPasswordNotification($token)); + } } \ No newline at end of file diff --git a/resources/theme/frontend/metronic/layouts/app.blade.php b/resources/theme/frontend/metronic/layouts/app.blade.php index 16d80f0..f45418b 100644 --- a/resources/theme/frontend/metronic/layouts/app.blade.php +++ b/resources/theme/frontend/metronic/layouts/app.blade.php @@ -23,7 +23,15 @@
- @yield('main-content') +
+
+ @yield('breadcrumb') + +
+ @yield('main-content') +
+
+
@@ -33,19 +41,21 @@ - {{-- BEGIN CORE PLUGINS (REQUIRED FOR ALL PAGES) --}} - @js('/site/js/jquery/1.11.2/js/jquery.min.js','jquery') - @js('/site/js/bootstrap/3.3.5/js/bootstrap.min.js','bootstrap-js','jquery') - @js('/site/js/jquery/plugins/migrate/1.2.1/js/jquery-migrate.min.js','jq-migrate','jquery') - @js('/site/js/jquery/plugins/back-to-top/back-to-top.js','back-to-top','jquery') - {{-- END CORE PLUGINS --}} + @section('scripts') + {{-- BEGIN CORE PLUGINS (REQUIRED FOR ALL PAGES) --}} + @js('/site/js/jquery/1.11.2/js/jquery.min.js','jquery') + @js('/site/js/bootstrap/3.3.5/js/bootstrap.min.js','bootstrap-js','jquery') + @js('/site/js/jquery/plugins/migrate/1.2.1/js/jquery-migrate.min.js','jq-migrate','jquery') + @js('/site/js/jquery/plugins/back-to-top/back-to-top.js','back-to-top','jquery') + {{-- END CORE PLUGINS --}} - {{-- Scripts --}} - {!! Asset::scripts() !!} + @include('layouts.partials.scripts') -@section('scripts') - @include('layouts.partials.scripts') -@show + {{-- Scripts --}} + {!! Asset::scripts() !!} + + @yield('page-scripts') + @show diff --git a/resources/theme/frontend/metronic/order.blade.php b/resources/theme/frontend/metronic/order.blade.php new file mode 100644 index 0000000..8821391 --- /dev/null +++ b/resources/theme/frontend/metronic/order.blade.php @@ -0,0 +1,246 @@ +@extends('layouts.app') + +@section('htmlheader_title') + {{ trans('message.home') }} +@endsection + +@section('main-content') +
+

Order Service

+ +
+
+
+ +
+ +
+
+
+
+
+ {{ csrf_field() }} + +
+ +
+
+

Register or Sign In

+
+ +
+
+
+ @if (Auth::user()) + {{ Auth::user()->name }} + @else + Login + @endif +
+ +
+
+
+
+ +
+
+ + + @if ($user->isReseller()) +
+
+

+ Client +

+
+ +
+
+
+
+ + + +
+
+
+ + + {{ $errors->first('order_email') }} +
+
+ +
+
+ + + {{ $errors->first('order_email') }} +
+ + + @if (FALSE AND Auth::user()->isBusiness()) +
+ + +
+
+
+
+
+ @endif +
+ +
+
+
+ +
+
+
+
+
+
+
+ @endif + + +
+
+

Product

+
+ +
+
+
+
+ + + {{ $errors->first('product_id') }} +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+@endsection + +@section('page-scripts') + @js('/js/jqBootstrapValidation.js','jq-validation','jquery') + + + + + +@append diff --git a/resources/theme/frontend/metronic/widgets/order/ADSL.blade.php b/resources/theme/frontend/metronic/widgets/order/ADSL.blade.php new file mode 100644 index 0000000..b86f899 --- /dev/null +++ b/resources/theme/frontend/metronic/widgets/order/ADSL.blade.php @@ -0,0 +1,9 @@ +
+ + +
+ + + {{ $errors->first('product_options.address') }} {{ $errors->first('product_options.address') }} +
+
\ No newline at end of file diff --git a/resources/theme/frontend/metronic/widgets/order/VOIP.blade.php b/resources/theme/frontend/metronic/widgets/order/VOIP.blade.php new file mode 100644 index 0000000..028c7e3 --- /dev/null +++ b/resources/theme/frontend/metronic/widgets/order/VOIP.blade.php @@ -0,0 +1,21 @@ +
+ + +
+ + + {{ $errors->first('product_options.phonenumber') }} {{ $errors->first('product_options.phonenumber') }} +
+ +
+ + + {{ $errors->first('product_options.supplier') }} {{ $errors->first('product_options.supplier') }} +
+ +
+ + + {{ $errors->first('product_options.supplieraccnum') }} {{ $errors->first('product_options.supplieraccnum') }} +
+
\ No newline at end of file diff --git a/resources/theme/frontend/metronic/widgets/product/ADSL.blade.php b/resources/theme/frontend/metronic/widgets/product/ADSL.blade.php new file mode 100644 index 0000000..0112857 --- /dev/null +++ b/resources/theme/frontend/metronic/widgets/product/ADSL.blade.php @@ -0,0 +1,30 @@ +
+

{{ $o->description }}

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeADSL
Setup CostTBA
Monthly CostTBA
Default BillingTBA
Contract TermTBA
Minimum CostsTBA
\ No newline at end of file diff --git a/resources/theme/frontend/metronic/widgets/product/VOIP.blade.php b/resources/theme/frontend/metronic/widgets/product/VOIP.blade.php new file mode 100644 index 0000000..d6f6fb0 --- /dev/null +++ b/resources/theme/frontend/metronic/widgets/product/VOIP.blade.php @@ -0,0 +1,30 @@ +
+

{{ $o->description }}

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeVOIP
Setup CostTBA
Monthly CostTBA
Default BillingTBA
Contract TermTBA
Minimum CostsTBA
\ No newline at end of file diff --git a/resources/theme/frontend/metronic/widgets/product_description.blade.php b/resources/theme/frontend/metronic/widgets/product_description.blade.php new file mode 100644 index 0000000..5d0fc34 --- /dev/null +++ b/resources/theme/frontend/metronic/widgets/product_description.blade.php @@ -0,0 +1,13 @@ +@if(View::exists('widgets.product.'.$o->category)) +
+
+
+ {{-- Return Category Requirements --}} + @include('widgets.product.'.$o->category) + + {{-- Return Supplier Requirements --}} + {{-- Return Product Requirements --}} +
+
+
+@endif \ No newline at end of file diff --git a/resources/theme/frontend/metronic/widgets/product_order.blade.php b/resources/theme/frontend/metronic/widgets/product_order.blade.php new file mode 100644 index 0000000..3c6a1d1 --- /dev/null +++ b/resources/theme/frontend/metronic/widgets/product_order.blade.php @@ -0,0 +1,18 @@ +@if(View::exists('widgets.order.'.$o->category)) +
+
+
+

Order Configuration

+
+ +
+ {{-- Return Category Requirements --}} + @include('widgets.order.'.$o->category) + + {{-- Return Supplier Requirements --}} + {{-- Return Product Requirements --}} +
+ +
+
+@endif \ No newline at end of file diff --git a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php new file mode 100644 index 0000000..53ea7c9 --- /dev/null +++ b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 0b914b5..899cab3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -29,4 +29,4 @@ Route::group(['middleware'=>'auth:api'], function() { Route::get('/u/invoices','UserServicesController@invoices'); Route::get('/u/payments','UserServicesController@payments'); Route::get('/u/services','UserServicesController@services'); -}); +}); \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4bc7b82..469697d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -46,8 +46,12 @@ Route::group(['middleware'=>['theme:adminlte-be','auth'],'prefix'=>'u'], functio // Frontend Routes (Non-Authed Users) Route::group(['middleware'=>['theme:metronic-fe']], function() { Route::get('/', 'WelcomeController@index'); + Route::get('order','OrderController@index'); + Route::post('order','OrderController@submit'); }); +Route::get('product_order/{o}', 'OrderController@product_order'); +Route::get('product_info/{o}', 'OrderController@product_info'); Route::redirect('/home','/u/home'); Route::demoAccess('/uc-access'); Route::redirect('/under-construction','http://www.graytech.net.au');