diff --git a/app/Http/Controllers/SupplierController.php b/app/Http/Controllers/SupplierController.php index 27f1cd7..02b2c18 100644 --- a/app/Http/Controllers/SupplierController.php +++ b/app/Http/Controllers/SupplierController.php @@ -8,7 +8,7 @@ use Illuminate\Support\Arr; use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit}; use App\Jobs\ImportCosts; -use App\Models\{Cost,Supplier,SupplierDetail}; +use App\Models\{Supplier,SupplierDetail}; class SupplierController extends Controller { @@ -24,7 +24,7 @@ class SupplierController extends Controller foreach (Arr::except($request->validated(),['supplier_details','api_key','api_secret','submit']) as $key => $item) $o->{$key} = $item; - $o->active = (bool)$request->active; + $o->active = (bool)$request->validated('active'); try { $o->save(); @@ -50,25 +50,6 @@ class SupplierController extends Controller ->with('success','Supplier Saved'); } - /** - * Show the suppliers invoice - * - * @param Cost $o - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - public function cost(Cost $o) - { - // @todo Need to add the services that are active that are not on the bill for the supplier. - return view('theme.backend.adminlte.supplier.cost.view') - ->with('o',$o); - } - - public function cost_add(Supplier $o) - { - return view('theme.backend.adminlte.supplier.cost.add') - ->with('o',$o); - } - public function cost_submit(Request $request,Supplier $o) { $request->validate([ diff --git a/app/Jobs/ImportCosts.php b/app/Jobs/ImportCosts.php index 56e3ef3..755c2cd 100644 --- a/app/Jobs/ImportCosts.php +++ b/app/Jobs/ImportCosts.php @@ -126,7 +126,7 @@ class ImportCosts implements ShouldQueue $cost = ($x=$this->getColumnKey('PRICETOTAL')) ? str_replace([',','$'],'',$fields[$x]) : NULL; $start_at = Carbon::createFromFormat('d M Y',$m[3]); $stop_at = Carbon::createFromFormat('d M Y',$m[4]); - $so = Service::search($m[1])->active()->with(['type','product.type.supplied'])->single(); + $so = Service::search($m[1])->ServiceActive()->with(['type','product.type.supplied'])->single(); if ($so) { // r[1] = Monthly Charge or Extra Charge,r[2] = "On Plan", r[3] = Plan Info @@ -197,7 +197,7 @@ class ImportCosts implements ShouldQueue } } else { - dump(['line'=>$line,'sql'=>Service::search($m[1])->active()->with(['type','product.type.supplied'])->toSql()]); + dump(['line'=>$line,'sql'=>Service::search($m[1])->ServiceActive()->with(['type','product.type.supplied'])->toSql()]); $to = Cost\Generic::where('site_id',$this->co->site_id) ->where('cost_id',$this->co->id) diff --git a/app/Models/Cost/Type.php b/app/Models/Cost/Type.php index bc82271..b1d705b 100644 --- a/app/Models/Cost/Type.php +++ b/app/Models/Cost/Type.php @@ -8,9 +8,9 @@ abstract class Type extends Model { public $timestamps = FALSE; - protected $dates = [ - 'start_at', - 'end_at', + protected $casts = [ + 'start_at' => 'datetime:Y-m-d', + 'end_at' => 'datetime:Y-m-d', ]; /* RELATIONS */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 40a4cbf..a7697e8 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Intuit\Traits\IntuitSocialite; -use App\Models\{Checkout,Payment,Product,Service,Supplier}; +use App\Models\{Checkout,Cost,Payment,Product,Service,Supplier}; class AppServiceProvider extends ServiceProvider { @@ -36,6 +36,7 @@ class AppServiceProvider extends ServiceProvider $this->bootIntuitSocialite(); Route::model('co',Checkout::class); + Route::model('cso',Cost::class); Route::model('po',Payment::class); Route::model('pdo',Product::class); Route::model('so',Service::class); diff --git a/resources/views/theme/backend/adminlte/supplier/cost/add.blade.php b/resources/views/theme/backend/adminlte/supplier/cost/add.blade.php index 704c21d..ffe5f19 100644 --- a/resources/views/theme/backend/adminlte/supplier/cost/add.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/cost/add.blade.php @@ -1,4 +1,6 @@ - +@use(Carbon\Carbon) + + @extends('adminlte::layouts.app') @section('htmlheader_title') @@ -9,47 +11,44 @@ Add Cost @endsection @section('contentheader_description') - {{ $o->name }} + {{ $spo->name }} @endsection @section('main-content')