How to populate Mailchimp Lists in drop down on selecting Mailchimp option
I want to show Mailchimp Lists when I click Mailchimp option from drop down I have already make API call to get lists from mailchimp now I want to populate this lists on drop down when I click Mailchimp from drop down.
My Html View:
<div class="new-intergrtain-sec clearfix">
<div class="form-group clearfix">
<label class="controllabel" for="select">Mailing List Integration</label>
<select class="slct-currncy required" id="select">
<option value="">--- Select Integration ---</option>
<option value="1">MailChimp</option>
</select>
</div>
<div class="form-group clearfix">
<label class="control-label" for="select2">Select Email Lists</label>
<select class="slct-currncy required" id="select2">
<option value="4"></option>
<option value="5">MailChimp</option>
</select>
</div>
</div>
My Controller where I am getting listing from mailchimp
public function getLists(Request $request)
{
$user_id = $request->user()->id;
$apikey = DB::table('user_mlc_mailchimp')->where('user_id','=', $user_id)->value('api_key');
if($apikey){
$mc = new MailChimp($apikey);
$mailchimp_ping = $mc->get('lists',['fields' => 'lists.id,lists.name', 'count' => 50]);
$mailchimp_ping = ['status' => 1, 'message' => 'Lists Found!', 'dataArray' => $mailchimp_ping];
return Response::json($mailchimp_ping, 200);
}
else {
$errorResponse = [
'message' => 'Lists not found!',
'error' => '401'
];
return Response::json( $errorResponse);
}
}
My Route is :
Route::get('lists', 'ApiController@getLists');
From these I am getting all the lists available on mailchimp with the required get route which I mentioned.
now I want to populate this on my drop down in my HTML view which I have shared with you and my HTML link is:
http://localhost:8000/New-Sale-Page
and its route :
$router->get('/New-Sale-Page', function () use ($router) {
return view('add-new-sale-page');
});
I have shared all the possible links from which u can help me I just want to show the mailchimp listing from drop down when I click mailchimp option,
Any help would be highly appreciated!
from Laravel Questions and Answers https://laravelquestions.com/php/how-to-populate-mailchimp-lists-in-drop-down-on-selecting-mailchimp-option/
via Lzo Media
No comments:
Post a Comment