From 5f66987a3eea2f467ce207d0dc74dc3ff2eea215 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 15 Aug 2024 21:30:34 +1000 Subject: [PATCH] Fixes for ordering, the themes are in frontend.metronic, not backend.adminlte --- app/Http/Controllers/OrderController.php | 54 ++++---- app/Models/Service.php | 4 +- config/themes.php | 115 ------------------ .../frontend/metronic/order/home.blade.php | 12 +- .../metronic/order/widget/info.blade.php | 6 +- .../metronic/order/widget/info/base.blade.php | 18 +-- .../order/widget/info/broadband.blade.php | 2 +- .../order/widget/info/domain.blade.php | 2 +- .../order/widget/info/email.blade.php | 2 +- .../order/widget/info/hosting.blade.php | 2 +- .../order/widget/info/phone.blade.php | 2 +- .../metronic/order/widget/order.blade.php | 6 +- .../order/widget/order/broadband.blade.php | 2 +- .../order/widget/order/domain.blade.php | 6 +- routes/web.php | 4 +- 15 files changed, 61 insertions(+), 176 deletions(-) delete mode 100644 config/themes.php diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php index 5de178f..5c1191c 100644 --- a/app/Http/Controllers/OrderController.php +++ b/app/Http/Controllers/OrderController.php @@ -9,40 +9,36 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Database\Eloquent\Model; use App\Mail\OrderRequest; -use App\Models\{Account,Product,Service,User}; +use App\Models\{Account,Product,Rtm,Service,User}; class OrderController extends Controller { - // @todo To check - public function product_order(Product $o) - { - return view('theme.backend.adminlte.order.widget.order') - ->with('o',$o); - } - - // @todo To check - public function product_info(Product $o) - { - return view('theme.backend.adminlte.order.widget.info') - ->with('o',$o); - } - // @todo To check public function submit(Request $request) { - Validator::make($request->all(),['product_id'=>'required|exists:products,id']) + Validator::make($request->all(), + [ + 'product_id'=>'required|exists:products,id' + ] + ) // Reseller - ->sometimes('account_id','required|email',function($input) use ($request) { - return is_null($input->account_id) AND is_null($input->order_email_manual); - }) + ->sometimes( + 'account_id', + 'required|email', + fn($input)=>is_null($input->account_id) && is_null($input->order_email_manual) + ) // Un-Authed User - ->sometimes('order_email_manual','required|email|unique:users,email,NULL,id',function($input) use ($request) { - return (is_null($input->order_email_manual) AND ! isset($input->account_id)) OR $input->order_email_manual; - }) + ->sometimes( + 'order_email_manual', + 'required|email|unique:users,email,NULL,id', + fn($input)=>(is_null($input->order_email_manual) && (! isset($input->account_id))) || $input->order_email_manual + ) // Authed User - ->sometimes('account_id','required|email',function($input) use ($request) { - return is_null($input->account_id) AND ! isset($input->order_email_manual); - }) + ->sometimes( + 'account_id', + 'required|email', + fn($input)=>is_null($input->account_id) && (! isset($input->order_email_manual)) + ) ->validate(); // Check the plugin details. @@ -72,7 +68,6 @@ class OrderController extends Controller // If we have a new account. if (is_null($request->input('account_id'))) { $ao = new Account; - //$ao->id = Account::NextId(); // @todo Make this automatic $ao->site_id = config('site')->site_id; $ao->country_id = config('site')->country_id; // @todo This might be wrong @@ -107,11 +102,12 @@ class OrderController extends Controller $order->save(); } - // @todo Move this email to a config item - Mail::to('help@graytech.net.au') + $ro = Rtm::where('parent_id',NULL)->sole(); + + Mail::to($ro->owner->email) ->queue((new OrderRequest($so,$request->input('options.notes') ?: ''))->onQueue('email')); //@todo Get email from DB. - return view('theme.backend.adminlte.order_received') + return view('theme.frontend.metronic.order_received') ->with('o',$so); } } \ No newline at end of file diff --git a/app/Models/Service.php b/app/Models/Service.php index b8ea279..e9b731e 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -16,7 +16,7 @@ use Leenooks\Casts\LeenooksCarbon; use App\Models\Product\Type; use App\Interfaces\IDs; -use App\Traits\{ScopeAccountUserAuthorised,ScopeServiceActive}; +use App\Traits\{ScopeAccountUserAuthorised,ScopeServiceActive,SiteID}; /** * Class Service @@ -52,7 +52,7 @@ use App\Traits\{ScopeAccountUserAuthorised,ScopeServiceActive}; */ class Service extends Model implements IDs { - use HasFactory,ScopeAccountUserAuthorised,ScopeServiceActive; + use HasFactory,ScopeAccountUserAuthorised,ScopeServiceActive,SiteID; protected $casts = [ 'order_info' => AsCollection::class, diff --git a/config/themes.php b/config/themes.php deleted file mode 100644 index e4544e3..0000000 --- a/config/themes.php +++ /dev/null @@ -1,115 +0,0 @@ - realpath(base_path('resources/views/theme')), // eg: base_path('resources/themes') - - /* - |-------------------------------------------------------------------------- - | Set behavior if an asset is not found in a Theme hierarchy. - | Available options: THROW_EXCEPTION | LOG_ERROR | IGNORE - |-------------------------------------------------------------------------- - */ - - 'asset_not_found' => 'THROW_EXCEPTION', - - /* - |-------------------------------------------------------------------------- - | Do we want a theme activated by default? Can be set at runtime with: - | Theme::set('theme-name'); - |-------------------------------------------------------------------------- - */ - - 'default' => null, - - /* - |-------------------------------------------------------------------------- - | Cache theme.json configuration files that are located in each theme's folder - | in order to avoid searching theme settings in the filesystem for each request - |-------------------------------------------------------------------------- - */ - - 'cache' => true, - - /* - |-------------------------------------------------------------------------- - | Define available themes. Format: - | - | 'theme-name' => [ - | 'extends' => 'theme-to-extend', // optional - | 'views-path' => 'path-to-views', // defaults to: resources/views/theme-name - | 'asset-path' => 'path-to-assets', // defaults to: public/theme-name - | - | // You can add your own custom keys - | // Use Theme::getSetting('key') & Theme::setSetting('key', 'value') to access them - | 'key' => 'value', - | ], - | - |-------------------------------------------------------------------------- - */ - - 'themes' => [ - - // Add your themes here. These settings will overide theme.json settings defined for each theme - - /* - |---------------------------[ Example Structure ]-------------------------- - | - | // Full theme Syntax: - | - | 'example1' => [ - | 'extends' => null, // doesn't extend any theme - | 'views-path' => example, // = resources/views/example_theme - | 'asset-path' => example, // = public/example_theme - | ], - | - | // Use all Defaults: - | - | 'example2', // Assets =\public\example2, Views =\resources\views\example2 - | // Note that if you use all default values, you can ommit decleration completely. - | // i.e. defaults will be used when you call Theme::set('undefined-theme') - | - | - | // This theme shares the views with example2 but defines its own assets in \public\example3 - | - | 'example3' => [ - | 'views-path' => 'example', - | ], - | - | // This theme extends example1 and may override SOME views\assets in its own paths - | - | 'example4' => [ - | 'extends' => 'example1', - | ], - | - |-------------------------------------------------------------------------- - */ - - 'metronic-fe' => [ - 'extends' => null, - 'views-path' => 'frontend/metronic', - 'asset-path' => 'theme/frontend/metronic', - ], - - 'metronic-be' => [ - 'extends' => null, - 'views-path' => 'backend/metronic', - 'asset-path' => 'theme/backend/metronic', - ], - - 'adminlte-be' => [ - 'extends' => null, - 'views-path' => 'backend/adminlte', - 'asset-path' => 'theme/backend/adminlte', - ], - ], -]; diff --git a/resources/views/theme/frontend/metronic/order/home.blade.php b/resources/views/theme/frontend/metronic/order/home.blade.php index 08c585c..1034534 100644 --- a/resources/views/theme/frontend/metronic/order/home.blade.php +++ b/resources/views/theme/frontend/metronic/order/home.blade.php @@ -1,3 +1,5 @@ +@use(App\Models\Product) + @extends('metronic::layouts.app') @section('htmlheader_title') @@ -184,13 +186,13 @@ - @foreach(\App\Models\TLD::orderBy('name')->get() as $oo) - + @foreach(TLD::orderBy('name')->get() as $oo) + @endforeach {{ $errors->first('options.tld') }} diff --git a/routes/web.php b/routes/web.php index 0b64688..aa3de39 100644 --- a/routes/web.php +++ b/routes/web.php @@ -223,5 +223,5 @@ Route::group(['prefix'=>'u'],function() { Route::view('order','theme.frontend.metronic.order.home'); Route::post('order',[OrderController::class,'submit']); -Route::get('product_order/{o}',[OrderController::class,'product_order']); -Route::get('product_info/{o}',[OrderController::class,'product_info']); \ No newline at end of file +Route::view('product_order/{pdo}','theme.frontend.metronic.order.widget.order'); +Route::view('product_info/{pdo}','theme.frontend.metronic.order.widget.info'); \ No newline at end of file