public function index(Request $request)
 {
     $now = new Carbon();
     if ($request->isMethod('post')) {
         $from = new Carbon($request->input('from', $now->toDateString()));
         $to = new Carbon($request->input('to', $now->toDateString()));
         $lessons = \App\Lesson::orderBy('given_at', 'asc')->where('given_at', '>=', $from->startOfDay()->toDateTimeString())->where('given_at', '<=', $to->endOfDay()->toDateTimeString())->get();
     } else {
         $lessons = \App\Lesson::orderBy('given_at', 'asc')->get();
     }
     $groups = \App\CustomerGroup::orderBy('groupname', 'desc')->get();
     return view('lesson.index')->with(['lessons' => $lessons, 'groups' => $groups, 'now' => $now->toDateString(), 'from' => isset($from) ? $from->toDateString() : '', 'to' => isset($to) ? $to->toDateString() : '']);
 }
 public function setUp()
 {
     parent::setUp();
     $this->user = \App\User::create(['name' => '*****@*****.**', 'email' => '*****@*****.**', 'password' => 'test']);
     $this->group = \App\CustomerGroup::create(['groupname' => 'Group 1']);
     $customer = \App\Customer::create(['firstname' => 'John', 'lastname' => 'Doe', 'phone' => '01234567891', 'group_id' => $this->group->id, 'email' => '*****@*****.**', 'birthday' => '1990-01-01']);
     $this->customers[] = $customer;
     $customer = \App\Customer::create(['firstname' => 'John', 'lastname' => 'Resig', 'phone' => '01234567891', 'group_id' => $this->group->id, 'email' => '*****@*****.**', 'birthday' => '1990-01-01']);
     $this->customers[] = $customer;
     $customer = \App\Customer::create(['firstname' => 'Taylor', 'lastname' => 'Otwell', 'phone' => '01234567891', 'group_id' => $this->group->id, 'email' => '*****@*****.**', 'birthday' => '1990-01-01']);
     $this->customers[] = $customer;
     foreach ($this->customers as $customer) {
         $customer->save();
     }
     $this->attendance[] = \App\Attendance::create(['group_id' => $this->group->id, 'customer_id' => $this->customers[0]->id, 'was_at' => new Carbon\Carbon('2015-01-01')]);
     $this->attendance[] = \App\Attendance::create(['group_id' => $this->group->id, 'customer_id' => $this->customers[1]->id, 'was_at' => new Carbon\Carbon('2015-01-01')]);
     $this->attendance[] = \App\Attendance::create(['group_id' => $this->group->id, 'customer_id' => $this->customers[2]->id, 'was_at' => new Carbon\Carbon('2015-01-01')]);
 }
 public function showCustomerForm()
 {
     $groups = ['' => ''] + CustomerGroup::lists('groupname', 'id');
     return view('customer/create')->with('groups', $groups)->withBody('customer-edit');
 }
 public function table()
 {
     $operations = ['<li><a href="{{route("customer-groups.edit", ["groupId" => $id])}}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit</a></li>', '<li><a href="{{route("customer-groups.remove", ["groupId" => $id])}}"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Remove</a></li>', '<li><a href="{{route("attendance.index", ["groupId" => $id])}}"><span class="glyphicon glyphicon-list" aria-hidden="true"></span> Attendace</a></li>'];
     $groups = CustomerGroup::select(['customer_group.id', 'customer_group.groupname']);
     return \Datatables::of($groups)->add_column('operations', '<ul class="operations">' . implode($operations) . '</ul>')->add_column('show', '{{route("customers.show", ["customerId" => $id])}}')->remove_column('id')->make(true);
 }
 public function edit($eventId)
 {
     $event = EventSchedule::findOrFail($eventId);
     $groups = CustomerGroup::lists('groupname', 'id');
     return view('event.edit')->with('event', $event)->with('start', null)->with('end', null)->with('dayOfWeek', null)->with('groups', $groups)->with('daysOfWeek', $this->daysOfWeek())->with('body', 'event-edit');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Currencies
     view()->composer(array('customers.edit', 'customer_invoices.create', 'companies.edit', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('currencyList', \App\Currency::lists('name', 'id'));
     });
     // Customer Groups
     view()->composer(array('customers.edit'), function ($view) {
         $view->with('customer_groupList', \App\CustomerGroup::lists('name', 'id'));
     });
     // Payment Methods
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('payment_methodList', \App\PaymentMethod::lists('name', 'id'));
     });
     // Sequences
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('sequenceList', \App\Sequence::lists('name', 'id'));
     });
     // Invoice Template
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('customerinvoicetemplateList', \App\Template::where('model_name', '=', 'CustomerInvoice')->lists('name', 'id'));
     });
     // Carriers
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('carrierList', \App\Carrier::lists('name', 'id'));
     });
     // Sales Representatives
     view()->composer(array('customers.edit', 'customer_invoices.create'), function ($view) {
         $view->with('salesrepList', \App\SalesRep::select(DB::raw('concat (firstname," ",lastname) as name, id'))->lists('name', 'id'));
     });
     // Price Lists
     view()->composer(array('customers.edit', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('price_listList', \App\PriceList::lists('name', 'id'));
     });
     // Warehouses
     view()->composer(array('products.create', 'stock_movements.create', 'configurationkeys.key_group_2', 'customer_invoices.create'), function ($view) {
         $whList = \App\Warehouse::with('address')->get();
         $list = [];
         foreach ($whList as $wh) {
             $list[$wh->id] = $wh->address->alias;
         }
         $view->with('warehouseList', $list);
         // $view->with('warehouseList', \App\Warehouse::lists('name', 'id'));
     });
     // Taxes
     view()->composer(array('customer_invoices.create', 'products.create', 'products.edit'), function ($view) {
         $view->with('taxList', \App\Tax::orderby('percent', 'desc')->lists('name', 'id'));
     });
     view()->composer(array('products.create', 'products.edit', 'customer_invoices.create'), function ($view) {
         $view->with('taxpercentList', \App\Tax::lists('percent', 'id'));
     });
     // Languages
     view()->composer(array('users.create', 'users.edit'), function ($view) {
         $view->with('languageList', \App\Language::lists('name', 'id'));
     });
     // Categories
     view()->composer(array('products.create', 'products._panel_main_data'), function ($view) {
         $view->with('categoryList', \App\Category::orderby('name', 'asc')->lists('name', 'id'));
     });
     // Stock Movement Types
     view()->composer(array('stock_movements.index', 'stock_movements.create'), function ($view) {
         $view->with('movement_typeList', \App\StockMovement::stockmovementList());
     });
 }