Exemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $_
  * @param  int  $id
  * @return Response
  */
 public function edit($_, $id)
 {
     $trainers = User::where('role_id', $this->trainerRoleId)->get();
     $trainers = $trainers->map(function ($user) {
         return ['id' => $user->id, 'name' => $user->present()->fullName . ' (' . $user->email . ')'];
     });
     $trainers->prepend(['id' => 0, 'name' => '']);
     return view('admin.groups.edit')->withGroup(Group::findOrFail($id))->withTrainers($trainers);
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $role = Role::findOrFail($id);
     $role->delete();
     if (Input::has('assign_role')) {
         $id = Input::get('role_id');
         if (Role::find($id)) {
             User::where('role_id', $role->id)->update(['role_id' => $id]);
         }
     }
     flash("Rolul <b>{$role->name}</b> a fost șters.", 'warning');
     return back();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $listName = $this->argument('list');
     $tid = config('auth.trainer_role_id');
     $users = User::where('county_id', 20)->get();
     foreach ($users as $user) {
         if (!$user->responses()->count() && (int) $user->role_id !== $tid) {
             echo $user->email . "\n";
             try {
                 $this->list->subscribeTo($listName, $user->email);
             } catch (\Mailchimp_ValidationError $e) {
                 echo $e->getMessage();
             }
         }
     }
     // $emails = [];
     // $failed = [];
     // foreach (Response::all() as $respoonse)
     // {
     // 	$email = $respoonse->user->email;
     // 	if (in_array($email, $emails)) continue;
     // 	if ( ! $respoonse->user->groups()->count('id'))
     // 	{
     // 		$emails[] = $email;
     // 		echo $email . "\n";
     // 		try
     // 		{
     // 			$this->list->subscribeTo($listName, $email);
     // 		}
     // 		catch (\Mailchimp_ValidationError $e)
     // 		{
     // 			echo $e->getMessage();
     // 			$failed[] = $email;
     // 		}
     // 	}
     // }
     // echo count($emails)." users added.\n".count($failed)." failed.";
     // $list = $this->list->getList();
     // $listId = $this->list->getListId($listName);
     // //print_r( $list->interestGroupings($listId) );
     // //exit;
     // $options = [
     //           'list_id' => $listId,
     //           'subject' => 'Test campaign',
     //           'from_name' => 'FII Practic',
     //           'from_email' => '*****@*****.**',
     //           'to_name' => 'Utilizator FII Practic'
     //       ];
     //       $content = [
     //           'html' => 'This is a test campaign',
     //           'text' => 'This is a test campaign'
     //       ];
     //       $segmentOpts = [
     //       	'match'=>'all',
     //       	'conditions' => [
     //       		[
     //       			'field' => 'interests-2113',
     //       			'op' => 'one',
     //       			'value' => 'GrupaA'
     //       		]
     //       	]
     //       ];
     //$mailchimp = new \Mailchimp;
     //$campaign = $mailchimp->campaigns->create('regular', $options, $content, $segmentOpts);
     // $mailchimp->campaigns->send($campaign['id']);
     // $this->list->getList()->interestGroupingAdd($listId, 'Test group', 'checkboxes', ['GrupaA', 'GroupB']);
     // $this->list->subscribeTo($listName, '*****@*****.**', [
     // 	'groupings' => [
     // 		'name' => 'Test group',
     // 		'groups' => ['GrupaA'],
     // 	]
     // ]);
 }