diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php index 624a84f..ace35b2 100644 --- a/app/Http/Controllers/OrderController.php +++ b/app/Http/Controllers/OrderController.php @@ -21,21 +21,21 @@ class OrderController extends Controller public function index() { - return view('order'); + return view('order.home'); } public function product_order(Product $o) { Theme::set('metronic-fe'); - return view('widgets.product_order',['o'=>$o]); + return view('order.widget.order',['o'=>$o]); } public function product_info(Product $o) { Theme::set('metronic-fe'); - return view('widgets.product_description',['o'=>$o]); + return view('order.widget.info',['o'=>$o]); } public function submit(Request $request) diff --git a/app/Models/PlanVoip.php b/app/Models/PlanVoip.php index 1cf4ed8..f5fc54e 100644 --- a/app/Models/PlanVoip.php +++ b/app/Models/PlanVoip.php @@ -14,25 +14,25 @@ class PlanVoip extends Model 'options.phonenumber'=>[ 'request'=>'options.phonenumber', 'key'=>'service_number', - 'validation'=>'required|size:10', + 'validation'=>'nullable|size:10|unique:ab_service__voip,service_number', 'validation_message'=>'Phone Number is a required field.', ], 'options.supplier'=>[ 'request'=>'options.supplier', 'key'=>'order_info.supplier', - 'validation'=>'required|min:4', + 'validation'=>'required_with:options.phonenumber', 'validation_message'=>'Phone Supplier is a required field.', ], 'options.supplieraccnum'=>[ 'request'=>'options.supplieraccnum', 'key'=>'order_info.supplieraccnum', - 'validation'=>'required|min:4', + 'validation'=>'required_with:options.phonenumber', 'validation_message'=>'Phone Supplier Account Number is a required field.', ], 'options.notes'=>[ 'request'=>'options.notes', 'key'=>'order_info.notes', - 'validation'=>'present', + 'validation'=>'required_if:options.phonenumber,null', 'validation_message'=>'Special Instructions here.', ], ]; diff --git a/app/Traits/OrderServiceOptions.php b/app/Traits/OrderServiceOptions.php index 24781b4..26e244f 100644 --- a/app/Traits/OrderServiceOptions.php +++ b/app/Traits/OrderServiceOptions.php @@ -5,6 +5,7 @@ */ namespace App\Traits; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; trait OrderServiceOptions @@ -22,23 +23,18 @@ trait OrderServiceOptions protected $order_model = NULL; */ - public function orderValidation(Request $request) + public function orderValidation(Request $request): ?Model { - if (! isset($this->order_attributes)) + if ((! isset($this->order_attributes)) || (! isset($this->order_model))) return NULL; - $request->validate(collect($this->order_attributes)->pluck('validation','request')->toArray()); - - if (! isset($this->order_model)) - return NULL; + $validate = $request->validate(collect($this->order_attributes)->pluck('validation','request')->toArray()); $o = new $this->order_model; $x = []; foreach ($this->order_attributes as $k => $v) - { $x[$v['key']] = $request->input($k); - } $o->forceFill(array_undot($x)); diff --git a/resources/views/theme/frontend/metronic/order.blade.php b/resources/views/theme/frontend/metronic/order/home.blade.php similarity index 82% rename from resources/views/theme/frontend/metronic/order.blade.php rename to resources/views/theme/frontend/metronic/order/home.blade.php index d9496c7..38e72a2 100644 --- a/resources/views/theme/frontend/metronic/order.blade.php +++ b/resources/views/theme/frontend/metronic/order/home.blade.php @@ -29,12 +29,10 @@
- @if (Auth::user() AND Auth::user()->isReseller()) + @if ($user && $user->isReseller())
-

- Account -

+

Account

@@ -43,12 +41,8 @@
@@ -77,7 +71,6 @@
-
@@ -85,7 +78,7 @@
- @elseif (Auth::user()) + @elseif ($user)

@@ -142,9 +135,6 @@ @else - @php - //dd($errors); - @endphp

@@ -181,44 +171,48 @@
-
-
- {{ $errors->first('product_options') }} +
+
+
+ {{ $errors->first('product_options') }} +
+ +
+ + + {{ $errors->first('product_id') }} +
-
- - - {{ $errors->first('product_id') }} -
@if (old('product_id')) - @include('widgets.product_description',['o'=>$po]) + @include('order.widget.info',['o'=>$po]) @endif
-
- @if (old('product_id')) - @include('widgets.product_order',['o'=>$po]) - @endif +
+
+ @if (old('product_id')) + @include('order.widget.order',['o'=>$po]) + @endif +
@@ -241,7 +235,9 @@
- + {{ $errors->first('options.notes') }}
@@ -252,15 +248,11 @@
-

- -
-

diff --git a/resources/views/theme/frontend/metronic/order/widget/info.blade.php b/resources/views/theme/frontend/metronic/order/widget/info.blade.php new file mode 100644 index 0000000..13f8da0 --- /dev/null +++ b/resources/views/theme/frontend/metronic/order/widget/info.blade.php @@ -0,0 +1,11 @@ +@if(View::exists('order.widget.info.'.$o->category)) +
+
+ {{-- Return Category Requirements --}} + @include('order.widget.info.'.$o->category) + + {{-- Return Supplier Requirements --}} + {{-- Return Product Requirements --}} +
+
+@endif \ No newline at end of file diff --git a/resources/views/theme/frontend/metronic/widgets/product/ADSL.blade.php b/resources/views/theme/frontend/metronic/order/widget/info/ADSL.blade.php similarity index 100% rename from resources/views/theme/frontend/metronic/widgets/product/ADSL.blade.php rename to resources/views/theme/frontend/metronic/order/widget/info/ADSL.blade.php diff --git a/resources/views/theme/frontend/metronic/widgets/product/VOIP.blade.php b/resources/views/theme/frontend/metronic/order/widget/info/VOIP.blade.php similarity index 100% rename from resources/views/theme/frontend/metronic/widgets/product/VOIP.blade.php rename to resources/views/theme/frontend/metronic/order/widget/info/VOIP.blade.php diff --git a/resources/views/theme/frontend/metronic/order/widget/order.blade.php b/resources/views/theme/frontend/metronic/order/widget/order.blade.php new file mode 100644 index 0000000..f28de81 --- /dev/null +++ b/resources/views/theme/frontend/metronic/order/widget/order.blade.php @@ -0,0 +1,16 @@ +@if(View::exists('order.widget.order.'.$o->category)) +
+
+

Order Configuration

+
+ +
+ {{-- Return Category Requirements --}} + @include('order.widget.order.'.$o->category) + + {{-- Return Supplier Requirements --}} + {{-- Return Product Requirements --}} +
+ +
+@endif \ No newline at end of file diff --git a/resources/views/theme/frontend/metronic/widgets/order/ADSL.blade.php b/resources/views/theme/frontend/metronic/order/widget/order/ADSL.blade.php similarity index 100% rename from resources/views/theme/frontend/metronic/widgets/order/ADSL.blade.php rename to resources/views/theme/frontend/metronic/order/widget/order/ADSL.blade.php diff --git a/resources/views/theme/frontend/metronic/widgets/order/VOIP.blade.php b/resources/views/theme/frontend/metronic/order/widget/order/VOIP.blade.php similarity index 100% rename from resources/views/theme/frontend/metronic/widgets/order/VOIP.blade.php rename to resources/views/theme/frontend/metronic/order/widget/order/VOIP.blade.php diff --git a/resources/views/theme/frontend/metronic/widgets/product_description.blade.php b/resources/views/theme/frontend/metronic/widgets/product_description.blade.php deleted file mode 100644 index 5d0fc34..0000000 --- a/resources/views/theme/frontend/metronic/widgets/product_description.blade.php +++ /dev/null @@ -1,13 +0,0 @@ -@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/views/theme/frontend/metronic/widgets/product_order.blade.php b/resources/views/theme/frontend/metronic/widgets/product_order.blade.php deleted file mode 100644 index 3c6a1d1..0000000 --- a/resources/views/theme/frontend/metronic/widgets/product_order.blade.php +++ /dev/null @@ -1,18 +0,0 @@ -@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