public function post(Step2Request $request)
 {
     // if id is found, update advisor
     if ($advisor_id = $request->input('id')) {
         $advisor = Advisor::find($advisor_id);
         $advisor->update($request->all());
     } else {
         // create new advisor
         $advisor = new Advisor($request->all());
         $advisor->school_id = Session::get('school')->id;
         $advisor->event_id = Session::get('event')->id;
         $advisor->save();
     }
     Session::set('advisor', Advisor::find($advisor->id));
     if (!$request->input('other_school')) {
         // auto create first advisor
         $attendee = new Attendee();
         // split up the attending advisor name
         $attendee_name = explode(' ', $request->input('attending_advisor'));
         if (is_array($attendee_name) && count($attendee_name) > 1) {
             $attendee->first_name = $attendee_name[0];
             $attendee->last_name = $attendee_name[1];
         } else {
             $attendee->first_name = $request->input('attending_advisor');
             $attendee->last_name = '';
         }
         $attendee->event_id = Session::get('event')->id;
         $attendee->school_id = Session::get('school')->id;
         $attendee->role_id = Role::where(['name' => 'Advisor', 'event_id' => Session::get('event')->id])->first()->id;
         $attendee->advisor_id = Session::get('advisor')->id;
         $attendee->save();
         Flash::info(trans('notifications.edit_as_needed'));
     }
     return redirect('/event/' . Session::get('event')->slug . '/step/3');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $advisor = new Advisor();
     $advisor->name = 'Testing Testerman';
     $advisor->email = '*****@*****.**';
     $advisor->attending_advisor = 'Testie Testerman';
     $advisor->comments = 'These are comments.';
     $advisor->event_id = 1;
     $advisor->school_id = 1;
     $advisor->save();
     $advisor = new Advisor();
     $advisor->name = 'Testing Testerman 2';
     $advisor->email = '*****@*****.**';
     $advisor->attending_advisor = 'Testie Testerman 2';
     $advisor->comments = 'These are comments.';
     $advisor->event_id = 1;
     $advisor->school_id = 1;
     $advisor->save();
 }
예제 #3
0
 /**
  * Checks if first advisor for the school.
  */
 public function shouldGetDiscount()
 {
     // has someone registered with this school already?
     if ($this->id == Advisor::where('school_id', $this->school->id)->orderBy('created_at', 'asc')->first()->id) {
         return true;
     } else {
         return false;
     }
 }
예제 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $advisor = Advisor::find($id);
     $advisor->delete();
     return redirect()->route('advisor.index');
 }
 /**
  * Output table data as csv.
  */
 public function export($format = 'csv')
 {
     // grab data
     $data = Advisor::select('advisors.id as AdvisorID', 'advisors.created_at as RegistrationTime', 'advisors.name as AdvisorName', 'schools.name as SchoolName', 'advisors.email as AdvisorEmail', 'advisors.attending_advisor as AttAdvisorResponsible', 'advisors.comments as Comments')->leftJoin('schools', 'schools.id', '=', 'advisors.school_id')->get();
     // create empty file
     $csv = Writer::createFromFileObject(new \SplTempFileObject());
     // create header
     $csv->insertOne(['AdvisorID', 'RegistrationTime', 'AdvisorName', 'SchoolName', 'AdvisorEmail', 'AttAdvisorResponsible', 'Comments']);
     // insert rows as associative array
     $csv->insertAll($data->toArray());
     $csv->output('advisors_' . \Carbon\Carbon::now()->timestamp . '.csv');
 }
예제 #6
0
<?php

$totals = \App\School::totals(Session::get('event')->id);
$advisor = \App\Advisor::find(Session::get('advisor'));
$total = $totals->flatten()->sum();
?>
<div class="widget stacked">
    <div class="widget-header">
        <i class="icon-star"></i>
        <h3>Invoice Summary</h3>
    </div> <!-- /widget-header -->
    <div class="widget-content">
        <table class="table">
            @foreach ($totals as $role => $charges)
                <tr>
                    <th align="right">{{ str_plural(\App\Role::find($role)->name) }}</th>
                    <td>{{ count($charges) }}</td>
                    <td>x ${{ \App\Role::find($role)->cost }} =</td>
                    <td align="right">${{ collect($charges)->sum() }}.00</td>
                </tr>
            @endforeach
            <tr>
                <th align="right">Total</th>
                <td colspan="3" align="right"><big><strong>${{ \App\School::total() }}.00</strong></big></td>
            </tr>
        </table>
    </div>
</div>
 public function index()
 {
     return view('step.parent', ['step' => 3, 'attendees' => Advisor::find(Session::get('advisor')->id)->attendees]);
 }