Mail Weiterleitung / verlauf / Notizen Buchnungen
This commit is contained in:
parent
f1a1baa913
commit
644ec93c53
47 changed files with 663 additions and 59 deletions
71
app/Http/Controllers/API/LeadController.php
Normal file
71
app/Http/Controllers/API/LeadController.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Models\Lead;
|
||||
use App\Models\Customer;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class LeadController extends Controller
|
||||
{
|
||||
public $successStatus = 200;
|
||||
public $errorStatus = 500;
|
||||
public $data = "";
|
||||
public $room_str = "";
|
||||
public $room_name = "";
|
||||
public $className = "";
|
||||
public $option = "";
|
||||
|
||||
public function action($action)
|
||||
{
|
||||
|
||||
if ($action == "create_lead") {
|
||||
$data = Request::all();
|
||||
|
||||
if(!isset($data['lead']) && !is_array($data['lead'])) {
|
||||
return response()->json(['error' => 'lead not exist, but need'], $this->errorStatus);
|
||||
}
|
||||
if(!isset($data['lead']['customerForm'])){
|
||||
return response()->json(['error' => 'lead customerForm not exist, but need'], $this->errorStatus);
|
||||
}
|
||||
|
||||
//customer
|
||||
/* $rules = array(
|
||||
'name' => 'required',
|
||||
'email' => 'requird'
|
||||
|
||||
);
|
||||
$validator = Validator::make($data['lead']['customerForm'], $rules);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->messages(), $this->errorStatus);
|
||||
|
||||
}
|
||||
|
||||
//lead
|
||||
$rules = array(
|
||||
'sf_guard_user_id' => 'required',
|
||||
'status_id' => 'requird',
|
||||
'request_date' => 'requird'
|
||||
);
|
||||
$validator = Validator::make($data['lead'], $rules);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->messages(), $this->errorStatus);
|
||||
|
||||
}*/
|
||||
|
||||
$customer = Customer::create($data['lead']['customerForm']);
|
||||
unset($data['lead']['customerForm']);
|
||||
$data['lead']['customer_id'] = $customer->id;
|
||||
$lead = Lead::create($data['lead']);
|
||||
$ret= [
|
||||
'url_v1' => make_old_url('/index.php/leads/'.$lead->id.'/edit'),
|
||||
'url_v3' => route('lead_detail', $lead->id),
|
||||
'lead_id' => $lead->id
|
||||
];
|
||||
|
||||
return response()->json(['success' => $ret], $this->successStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue