Exemplo n.º 1
0
 public function close($orgId, $id)
 {
     $orgOrder = OrganizationOrder::findOrFail($id);
     $orgOrder->closed_at = date('Y-m-d H:i:s');
     $orgOrder->save();
     return redirect()->route('orgorder.index', ['orgId' => $orgId]);
 }
Exemplo n.º 2
0
 public function store(Request $request, $id)
 {
     $orgOrder = OrganizationOrder::findOrFail($id);
     $lineItem = new LineItem();
     $lineItem->organization_order_id = $id;
     if ($request->input('UserOrder') && strlen($request->input('UserOrder')['order']) > 0) {
         if ($request->input('UserOrder')['default'] == 1) {
             UserOrder::where('user_id', '=', $request->user()->id)->where('restaurant_id', '=', $orgOrder->restaurant()->id)->where('default', '=', '1')->update(['default' => 0]);
         }
         $userOrder = new UserOrder();
         $userOrder->fill($request->input('UserOrder'));
         $userOrder->user_id = $request->user()->id;
         $userOrder->restaurant_id = $orgOrder->restaurant()->id;
         $userOrder->save();
         $lineItem->user_order = $userOrder->id;
     } else {
         $lineItem->user_order = $request->input('LineItem')['user_order'];
     }
     if ($lineItem->isValid()) {
         $lineItem->save();
         return redirect()->route('orgorder.show', ['orgId' => $orgOrder->organization()->id, 'id' => $lineItem->organization_order_id]);
     } else {
         return redirect()->route('lineitem.create', ['id' => $id])->withErrors($lineItem->getErrors())->withInput();
     }
 }
Exemplo n.º 3
0
 public function outgoingOrder(Request $request, $id)
 {
     $organization = Organization::findOrFail($id);
     $order = OrganizationOrder::orderBy('created_at', 'desc')->first();
     $message = "Today's lunch will be " . $order->restaurant()->name . "!";
     $message .= " Make sure to <" . route('lineitem.create', [$order->id]) . "|put in your order>!";
     $body = json_encode(['text' => $message]);
     $client = new \GuzzleHttp\Client();
     $res = $client->post($organization->incoming_slack_link, ['body' => $body]);
     return redirect()->route('organization.view', [$organization->id]);
 }
Exemplo n.º 4
0
 public function run()
 {
     Artisan::call('migrate:refresh');
     $user = \App\User::create(['email' => '*****@*****.**', 'password' => '$2y$10$zhRDGljo5k5jn6oifVCA7.4GzB6OKmV1QkJfvErtcheR0m5jMLK9S', 'firstName' => 'ftesting1', 'lastName' => 'ltesting1']);
     $restaurant = \App\Restaurant::create(['name' => 'Burger King']);
     $organization = \App\Organization::create(['name' => 'Testing1']);
     $poll = \App\Poll::create(['closed_at' => '2017-05-18 03:00:00', 'closed_by' => '2017-05-18 04:00:00', 'organization_id' => 1]);
     $organization->restaurants()->save($restaurant);
     $poll->restaurants()->save($restaurant);
     $role = \App\Role::create(['user_id' => 1, 'organization_id' => 1, 'role' => 'Tester']);
     $organization_order = \App\OrganizationOrder::create(['organization_restaurant_id' => 1, 'due_by' => '2017-05-18 04:00:00', 'closed_at' => '2017-05-18 03:00:00']);
     $user_order = \App\UserOrder::create(['user_id' => 1, 'restaurant_id' => 1, 'default' => 1, 'order' => 'Test Burger']);
     $polloption = \App\PollRestaurant::find(1);
     $polloption->users()->save($user);
 }
Exemplo n.º 5
0
 public function orders()
 {
     return \App\OrganizationOrder::join('organizations_restaurants', 'organization_orders.organization_restaurant_id', '=', 'organizations_restaurants.id')->where('organizations_restaurants.organization_id', '=', $this->id)->orderBy('organization_orders.created_at', 'desc')->select('organization_orders.*')->get();
 }