我对 Laravel 很陌生。我有一个名为Leads的表和一个名为 Contacts , Company 和 Opportunities 的其他表三个强>。 我想做的是将Leads表中的数据提取到其他3个表中。这样的东西:https://imgur.com/EZGqNQH。我要达到的目的是这样的:当用户单击“转换潜在客户”按钮时,将出现一个模态:https://imgur.com/EDgVR7U,如果用户在“转换为机会”的复选框上打了勾,将显示一个额外的字段供用户填写:https://imgur.com/mrypfCC
我已经为该过程制作了必要的文件
LeadController:
{
return view('leads.create')
->withUsers($this->users->getAllUsersWithDepartments())
->withClients($this->clients->listAllClients())
->withIndustries($this->clients->listAllIndustries())
->withLeadSource($this->leads->listAllSources());
}
public function convertLeads($id)
{
$lead = Lead::findOrFail($id);
$company = new Companies;
$opportunity = new Opportunity;
$contact = new Contact;
$company->lead_id = $lead->id;
$company->name = $lead->company_name;
$company->phone = $lead->company_phone;
$company->email = $lead->company_mail;
$company->address1 = $lead->company_address1;
$company->address2 = $lead->company_address2;
$company->state = $lead->company_state;
$company->zipcode = $lead->company_zipcode;
$company->city = $lead->company_city;
$company->country = $lead->company_country;
$company->save();
$contact->name = $lead->lead_name;
$contact->job_title = $lead->position;
$contact->email = $lead->mail;
$contact->primary_number = $lead->lead_phone;
$contact->description = $lead->description;
$contact->client_id = $lead->client_id;
$contact->save();
Session()->flash('flash_message', 'Lead successfully converted!');
return view('leads.show');
}
/**
* Store a newly created resource in storage.
*
* @param StoreLeadRequest|Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(StoreLeadRequest $request)
{
$getInsertedId = $this->leads->create($request);
Session()->flash('flash_message', 'Lead is created');
return redirect()->route('leads.show', $getInsertedId);
}
public function show($id)
{
return view('leads.show')
->withLead($this->leads->find($id))
->withUsers($this->users->getAllUsersWithDepartments())
->withCompanyname($this->settings->getCompanyName());
}
路线:
Route::get('/data', 'LeadsController@anyData')->name('leads.data');
Route::get('/create', 'LeadsController@create')->name('leads.create');
Route::get('/show/{id}', 'LeadsController@show')->name('leads.show');
Route::get('convertLeads/{id}', 'LeadsController@convertLeads')->name('leads.convertLeads');
Route::get('/my', 'LeadsController@my')->name('leads.my');
Route::get('/mydata', 'LeadsController@myData')->name('leads.mydata');
Route::patch('/updateassign/{id}', 'LeadsController@updateAssign');
Route::patch('/updatestatus/{id}', 'LeadsController@updateStatus');
Route::patch('/updatefollowup/{id}', 'LeadsController@updateFollowup')->name('leads.followup');
});
Route::resource('leads', 'LeadsController');
Route::post('/comments/{type}/{id}', 'CommentController@store');
观看次数:
<div>
<table width="100%">
<tr>
<th></th>
</tr>
<tr>
{!!Form::open(array('route' => array('leads.convertLeads', $lead->id)))!!}
<td><li>Convert to Contact</li></td>
</tr>
<tr>
<td><li>Convert to Company</li></td>
</tr>
<tr>
<td><label for="chkOpportunity">
<input type="checkbox" id="chkOpportunity" />
Convert to Opportunity
</label>
<div id="dvOpportunity" style="display: none">
{!! Form::label('name', __('Lead Name'), ['class' => 'control-label']) !!}
<div class="form-group" style="padding:5px">
{!! Form::label('country', __('Value'), ['class' => 'control-label']) !!}
{!! Form::text('company_country', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group" style="padding:5px">
{!! Form::label('country', __('Type'), ['class' => 'control-label']) !!}
{!! Form::text('company_country', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group" style="padding:5px">
{!! Form::label('country', __('Stage'), ['class' => 'control-label']) !!}
{!! Form::text('company_country', null, ['class' => 'form-control']) !!}
{!! Form::close() !!}
</div>
</div>
</td>
</tr>
</table>
<div class="modal-footer" style="margin:-13px; margin-top:4px;">
<div align="right">
{!! Form::submit(__('Convert Lead'), ['class' => 'btn btn-primary']) !!}
</div>
</div>
</div>
</div>
我不确定其中哪一部分是错误的,我认为这是表格吗?当我单击“转换潜在客户”按钮(提交)时,什么都没有发生。有人可以帮忙吗?预先感谢。
答案 0 :(得分:0)
尝试将表格放在表格标签上方
喜欢
<div>{!!Form::open(array('route' => array('leads.convertLeads', $lead->id)))!!}
<table width="100%">
<tr>
<th></th>
</tr>
<tr>
<td><li>Convert to Contact</li></td>