deal updated
This commit is contained in:
parent
f490c32bc0
commit
c896647a35
@ -4,7 +4,7 @@
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Deal;
|
||||
use App\Models\Deal\Deal;
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\City;
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Deal;
|
||||
use App\Models\Deal\Deal;
|
||||
use App\Models\Deal\DealStatus;
|
||||
|
||||
class ConfirmClientFromBitrix extends Controller
|
||||
{
|
||||
@ -13,11 +13,11 @@ public function confirm(Request $request)
|
||||
$deal = Deal::where('confirm_token', $request->hash)->first();
|
||||
if ($request->is_unique == true)
|
||||
{
|
||||
$deal->is_unique = true;
|
||||
$deal->status = DealStatus::UNIQUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$deal->is_unique = false;
|
||||
$deal->is_unique = DealStatus::NOT_UNIQUE;
|
||||
}
|
||||
$deal->save();
|
||||
return $deal->id;
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
use App\Models\Company\CompanyAdmin;
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\Agent\AgentStatus;
|
||||
use App\Models\Deal;
|
||||
use App\Models\Deal\Deal;
|
||||
|
||||
class AgentsTable extends Component
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
use Livewire\WithoutUrlPagination;
|
||||
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\Deal;
|
||||
use App\Models\Deal\Deal;
|
||||
|
||||
class ClientsTable extends Component
|
||||
{
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\User;
|
||||
use App\Models\Deal;
|
||||
use App\Models\Deal\Deal;
|
||||
use App\Models\Deal\DealStatus;
|
||||
use App\Models\Complex;
|
||||
use App\Models\Status;
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\Bitrix\SendClient;
|
||||
|
||||
@ -126,12 +126,13 @@ public function save()
|
||||
'complex_id' => $this->client['complexId']
|
||||
];
|
||||
$data['confirm_token'] = $this->client['confirmToken'] = hash('sha256', json_encode($data));
|
||||
|
||||
if ($newDeal = Deal::create($data))
|
||||
{
|
||||
if ($bitrixId = $this->sendToBitrix($newDeal->id))
|
||||
{
|
||||
$newDeal->bitrix_id = $bitrixId;
|
||||
$newDeal->status = 'MODERATION';
|
||||
$newDeal->status = DealStatus::MODERATION;
|
||||
$newDeal->save();
|
||||
$this->result = $bitrixId;
|
||||
return $this->status = self::SUCCESS;
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\User;
|
||||
use App\Models\Deal;
|
||||
use App\Models\Deal\Deal;
|
||||
|
||||
class Agent extends Model
|
||||
{
|
||||
|
||||
@ -10,14 +10,17 @@ class Details
|
||||
{
|
||||
use HasFactory;
|
||||
public $details;
|
||||
public function __construct(Company $company) {
|
||||
public function __construct(Company $company)
|
||||
{
|
||||
$company;
|
||||
if (!$company->details) {
|
||||
if (!$company->details)
|
||||
{
|
||||
if ($company->type == 'SELFEMP')
|
||||
{
|
||||
$company->details = $this->emptyForSelfEmp();
|
||||
$company->save();
|
||||
};
|
||||
}
|
||||
;
|
||||
if ($company->type == 'AGENCY')
|
||||
{
|
||||
$company->details = $this->emptyForAgency();
|
||||
@ -27,7 +30,8 @@ public function __construct(Company $company) {
|
||||
$this->details = $company->details;
|
||||
}
|
||||
|
||||
private function emptyForSelfEmp() {
|
||||
private function emptyForSelfEmp()
|
||||
{
|
||||
$data = [
|
||||
'user' => [
|
||||
'firstName' => '',
|
||||
@ -51,7 +55,8 @@ private function emptyForSelfEmp() {
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function emptyForAgency() {
|
||||
private function emptyForAgency()
|
||||
{
|
||||
$data = [
|
||||
'name' => '',
|
||||
'fullName' => '',
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Deal;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -17,11 +17,13 @@ class Deal extends Model
|
||||
'confirm_token'
|
||||
];
|
||||
|
||||
public function complex() {
|
||||
public function complex()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Complex::class);
|
||||
}
|
||||
|
||||
public function user() {
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'client_id');
|
||||
}
|
||||
}
|
||||
11
app/Models/Deal/DealStatus.php
Normal file
11
app/Models/Deal/DealStatus.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Deal;
|
||||
|
||||
final class DealStatus
|
||||
{
|
||||
public const NEW = 'NEW';
|
||||
public const MODERATION = 'MODERATION';
|
||||
public const UNIQUE = 'UNIQUE';
|
||||
public const NOT_UNIQUE = 'NOT UNIQUE';
|
||||
}
|
||||
@ -11,7 +11,8 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('deals', function (Blueprint $table) {
|
||||
Schema::create('deals', function (Blueprint $table)
|
||||
{
|
||||
$table->id();
|
||||
$table->foreignId('client_id')->references('id')->on('users');
|
||||
$table->foreignId('complex_id')->references('id')->on('complexes')->onDelete('cascade');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user