public function run()
 {
     Eloquent::unguard();
     DB::table('services')->truncate();
     DB::table('service_options')->truncate();
     DB::table('billing_cycles')->truncate();
     $faker = Faker\Factory::create();
     $service = Service::create(array('name' => 'Simful Travel', 'description' => 'Complete solution for travel agents'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Economy', 'base_price' => '15', 'description' => 'Designed for small, starter agents.'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Professional', 'base_price' => '24', 'description' => 'Great for small and mid-size agents.'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Super', 'base_price' => '45', 'description' => 'For mid-size to large agents.'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Ultima', 'base_price' => '125', 'description' => 'For the enterprise level.'));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 3, 'discount' => 5));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 6, 'discount' => 10));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 12, 'discount' => 20));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 24, 'discount' => 25));
     for ($i = 0; $i < 10; $i++) {
         $service = Service::create(array('name' => studly_case($faker->domainWord), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Economy', 'base_price' => $faker->randomNumber(1, 15), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Professional', 'base_price' => $faker->randomNumber(16, 35), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Super', 'base_price' => $faker->randomNumber(36, 100), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Ultima', 'base_price' => $faker->randomNumber(101, 200), 'description' => $faker->sentence));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 3, 'discount' => 5));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 6, 'discount' => 10));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 12, 'discount' => 20));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 24, 'discount' => 25));
     }
 }
 function checkout()
 {
     // process cart items
     if (count(Cart::contents()) < 1) {
         return Redirect::to('order');
     }
     $items = Cart::contents();
     $invoice_id = DB::table('invoices')->insertGetId(array('user_id' => Auth::user()->id, 'due_date' => date('Y-m-d'), 'status' => 'Unpaid'));
     foreach ($items as $item) {
         // to ensure the shopping cart was not manipulated, we use the option directly, not from the price
         $option = ServiceOption::find($item->id);
         // build description string
         $description = $option->service->name . ' ' . $option->name . ' recurring every ' . $item->quantity . ' month(s)';
         DB::table('invoice_items')->insert(array('invoice_id' => $invoice_id, 'description' => $description, 'unit_price' => $item->price));
     }
     // push invoice to e-mail queue
     // empty the cart
     Cart::destroy();
     return Redirect::to('order/thankyou');
 }
Example #3
0
            return Redirect::to('client/dashboard');
        }
    } else {
        return View::make('client.portal');
    }
});
Route::get('dashboard', 'HomeController@statistics');
Route::get('me', function () {
    if (Auth::check()) {
        return json_encode(array('username' => Auth::user()->username, 'email' => Auth::user()->email, 'pic' => '//www.gravatar.com/avatar/' . md5(strtolower(trim(Auth::user()->email))) . '?s=64', 'profile' => Auth::user()->profile->toArray()));
    } else {
        return json_encode(null);
    }
});
Route::get('t', function () {
    $query = ServiceOption::find(2);
    return var_dump($query->service);
});
Route::get('templates/clone/{id}', function ($id) {
});
Route::get('user/create', 'UserController@create');
Route::post('user', 'UserController@store');
Route::get('user/login', 'UserController@login');
Route::post('user/login', 'UserController@do_login');
Route::get('user/confirm/{code}', 'UserController@confirm');
Route::get('user/forgot_password', 'UserController@forgot_password');
Route::post('user/forgot_password', 'UserController@do_forgot_password');
Route::get('user/reset_password/{token}', 'UserController@reset_password');
Route::post('user/reset_password', 'UserController@do_reset_password');
Route::get('user/logout', 'UserController@logout');
Route::get('user/settings', 'UserController@settings');