diff --git a/app/Models/Deal/Contract.php b/app/Models/Deal/Contract.php index 208a2e0..0568863 100644 --- a/app/Models/Deal/Contract.php +++ b/app/Models/Deal/Contract.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; - +use App\Models\Deal\ContractStatus; class Contract extends Model { use HasFactory; @@ -31,4 +31,9 @@ public function deal() { return $this->belongsTo(Deal::class, 'deal_id'); } + + public function getStatus() + { + + } } diff --git a/app/Models/Deal/ContractStatus.php b/app/Models/Deal/ContractStatus.php index 7602cca..fc75aff 100644 --- a/app/Models/Deal/ContractStatus.php +++ b/app/Models/Deal/ContractStatus.php @@ -1,11 +1,26 @@ where('bitrixable_type', get_class(new Deal())); //Загрузка сделок - if (BitrixId::where('bx_id', $deal['deal']['deal_id'])->count() == 0) + if ($bitrixId->count() == 0) { $dealItem = Deal::create([ 'client_id' => $client->id, @@ -64,6 +73,23 @@ public function syncDeals(Agent $agent) ]); $dealItem->setBitrixId($deal['deal']['deal_id']); } + else + { + $bitrixId = $bitrixId->first(); + $dealItem = Deal::find($bitrixId->bitrixable_id); + } + ; + $inDeal = $deal['deal']; + $contract = Contract::updateOrCreate( + ['deal_id' => $dealItem->id], + [ + 'price' => $inDeal['price'], + 'square' => $inDeal['square'], + 'floor' => $inDeal['floor'], + 'room' => $inDeal['room'], + 'plan7_id' => $inDeal['plan7_id'] + ] + ); } } } \ No newline at end of file diff --git a/app/Modules/Contracts/Http/Controllers/ContractsController.php b/app/Modules/Contracts/Http/Controllers/ContractsController.php index 0dd602b..926a1b7 100644 --- a/app/Modules/Contracts/Http/Controllers/ContractsController.php +++ b/app/Modules/Contracts/Http/Controllers/ContractsController.php @@ -12,6 +12,8 @@ class ContractsController extends Controller { public function index() { - return view('contracts::index'); + return view('contracts::index', [ + 'status' => 'all' + ]); } } \ No newline at end of file diff --git a/app/Modules/Contracts/Http/Livewire/ContractsTableLivewire.php b/app/Modules/Contracts/Http/Livewire/ContractsTableLivewire.php new file mode 100644 index 0000000..ae4b919 --- /dev/null +++ b/app/Modules/Contracts/Http/Livewire/ContractsTableLivewire.php @@ -0,0 +1,27 @@ + $contracts, + 'statuses' => ContractStatus::class + ]); + } +} \ No newline at end of file diff --git a/app/Modules/Contracts/Providers/ModuleServiceProvider.php b/app/Modules/Contracts/Providers/ModuleServiceProvider.php index c0727ff..c7a5e6d 100644 --- a/app/Modules/Contracts/Providers/ModuleServiceProvider.php +++ b/app/Modules/Contracts/Providers/ModuleServiceProvider.php @@ -1,6 +1,6 @@ loadViewsFrom( - $moduleViewsPath, strtolower($this->moduleName) + $moduleViewsPath, + strtolower($this->moduleName) ); } protected function registerLivewireViews() { - $moduleViewsPath = __DIR__.'/../Views/livewire'; + $moduleViewsPath = __DIR__ . '/../Views/livewire'; $this->loadViewsFrom( - $moduleViewsPath, strtolower($this->moduleName) + $moduleViewsPath, + strtolower($this->moduleName) ); } protected function registerMigrations() { $this->loadMigrationsFrom( - app_path('Modules/'.$this->moduleName.'/Database/Migrations') + app_path('Modules/' . $this->moduleName . '/Database/Migrations') ); } protected function registerConfig() { - $path = app_path('Modules/'.$this->moduleName.'/Config/config.php'); + $path = app_path('Modules/' . $this->moduleName . '/Config/config.php'); $this->mergeConfigFrom( - $path, strtolower($this->moduleName) + $path, + strtolower($this->moduleName) ); } protected function registerLivewire() { //Livewire::component('', \Modules\\Http\Livewire\::class); + Livewire::component('contracts.table', \Modules\Contracts\Http\Livewire\ContractsTableLivewire::class); } protected function registerComponent() diff --git a/app/Modules/Contracts/Providers/RouteServiceProvider.php b/app/Modules/Contracts/Providers/RouteServiceProvider.php index 6f69b87..dfc0f49 100644 --- a/app/Modules/Contracts/Providers/RouteServiceProvider.php +++ b/app/Modules/Contracts/Providers/RouteServiceProvider.php @@ -1,6 +1,6 @@ namespace('Modules\\Contract\\Http\\Controllers') - ->group(app_path('Modules/Contract/Routes/web.php')); + ->namespace('Modules\\Contracts\\Http\\Controllers') + ->group(app_path('Modules/Contracts/Routes/web.php')); } } \ No newline at end of file diff --git a/app/Modules/Contracts/Routes/web.php b/app/Modules/Contracts/Routes/web.php index 2eb49f0..7d3ad78 100644 --- a/app/Modules/Contracts/Routes/web.php +++ b/app/Modules/Contracts/Routes/web.php @@ -3,11 +3,7 @@ use Illuminate\Support\Facades\Route; use Modules\Contracts\Http\Controllers\ContractsController; -Route::middleware(['auth'])->group(function() { - - Route::get('/contract', [ContractsController::class, 'index']); - - Route::middleware(['hasAccess'])->group(function() { - /** Routes that need to be protected - Маршруты которые нужно защитить */ - }); +Route::middleware(['auth'])->group(function () +{ + Route::get('/contracts', [ContractsController::class, 'index'])->name('contracts'); }); \ No newline at end of file diff --git a/app/Modules/Contracts/Views/index.blade.php b/app/Modules/Contracts/Views/index.blade.php index f8198cf..ffdc4c7 100644 --- a/app/Modules/Contracts/Views/index.blade.php +++ b/app/Modules/Contracts/Views/index.blade.php @@ -1,4 +1,46 @@ @extends('layouts.app') - @section('content') -

Example views

- @endsection \ No newline at end of file +@section('content') +
+
+
+ + + + + +
+
+
Всего: 136 договоров
+ +
+
+ +
+
+ @livewire('contracts.table') +
+ + + +@endsection diff --git a/app/Modules/Contracts/Views/livewire/table/index.blade.php b/app/Modules/Contracts/Views/livewire/table/index.blade.php new file mode 100644 index 0000000..74c4654 --- /dev/null +++ b/app/Modules/Contracts/Views/livewire/table/index.blade.php @@ -0,0 +1,65 @@ +@php($statuses = App\Models\Deal\ContractStatus::class) +
+
+ + + + + + + @foreach ($contracts as $contract) + + + + + + + + + + + @endforeach + +
Клиент + Город + ЖК + Площадь + Сумма + Вознаграждение + Статус + +
+ {{ $contract->deal->user->name }} + + {{ $contract->deal->complex->city->name }} + + {{ $contract->deal->complex->name }} + + {{ $contract->square }} + + {{ $contract->price }} + + {{ $contract->reward }} + +
+ {{ $statuses::getName($contract->status) }} +
+
+ +
+
+
diff --git a/lang/ru/contracts.php b/lang/ru/contracts.php new file mode 100644 index 0000000..6a7225c --- /dev/null +++ b/lang/ru/contracts.php @@ -0,0 +1,9 @@ + 'Новый', + 'status_TREATY' => 'Выплачено', + 'status_RESERVATION' => 'Забронировано', + 'status_SUSSCESS' => 'Успех', + 'status_DECLINE' => 'Отклонен' + +]; \ No newline at end of file diff --git a/resources/views/clients/contract/index.blade.php b/resources/views/clients/contract/index.blade.php index d17f5b3..de5f6cf 100644 --- a/resources/views/clients/contract/index.blade.php +++ b/resources/views/clients/contract/index.blade.php @@ -37,20 +37,20 @@ class="bi bi-arrow-right" viewBox="0 0 16 16">
+ + + + + -->
diff --git a/resources/views/clients/table.blade.php b/resources/views/clients/table.blade.php index f12c377..8a24760 100644 --- a/resources/views/clients/table.blade.php +++ b/resources/views/clients/table.blade.php @@ -17,14 +17,6 @@ -
+ + + --> diff --git a/resources/views/livewire/main-menu.blade.php b/resources/views/livewire/main-menu.blade.php index 4f7548f..5801a0e 100644 --- a/resources/views/livewire/main-menu.blade.php +++ b/resources/views/livewire/main-menu.blade.php @@ -18,12 +18,11 @@ $items[] = [ 'target' => 'route', - 'route' => 'clients.table', + 'route' => 'contracts', 'name' => 'Договоры', 'icon' => 'files-alt', ]; -} -if (in_array($roles::AGENT, $userRoles) || in_array($roles::COMPANY_ADMIN, $userRoles)) { + $items[] = [ 'target' => 'modal', 'modal' => '#plan7Modal',