public function run() { DB::table('todos')->truncate(); foreach (Organization::all() as $org) { Todo::create(['name' => 'First Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id, 'completed' => true]); Todo::create(['name' => 'Second Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id]); Todo::create(['name' => 'Todo from Second', 'user_id' => $org->users[1]->id, 'organization_id' => $org->id]); Todo::create(['name' => 'Third Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id]); } }
/** * Run the migrations. * * @return void */ public function up() { DB::transaction(function () { Schema::table('organizations', function (Blueprint $table) { $table->string('slug', 255)->nullable()->index(); }); foreach (Organization::all() as $org) { $org->slug = Str::slug($org->name); $org->save(); } }); }
public function run() { DB::table('users')->truncate(); DB::table('organization_user')->truncate(); $usernames = ['machuga', 'second', 'third', 'admin']; foreach (Organization::all() as $org) { foreach ($usernames as $username) { $username = $org->isVendor() ? $username : $username . $org->id; $user = User::create(['name' => ucfirst($username), 'email' => "{$username}@example.com", 'password' => $username, 'active' => true, 'admin' => starts_with($username, 'admin')]); $user->organizations()->attach($org->id); } } }
/** * @test */ public function getPlatforms() { $orgs = \Organization::all([], ['_id']); $results = []; foreach ($orgs as $o) { $platforms = \Platform::rssFeeds($o); $count = count($platforms); if ($count === 0) { continue; } $results = array_merge($results, $platforms); } $this->assertNotEquals(0, count($results)); return $results; }
public function run() { DB::table('users')->truncate(); $usernames = ['tonetlds', 'demo', 'admin']; foreach (Organization::all() as $org) { foreach ($usernames as $username) { $username = $username . '-' . $org->name; User::create(['organization_id' => $org->id, 'username' => $username, 'email' => $username . '@lucianotonet.com', 'password' => $username, 'password_confirmation' => $username, 'confirmation_code' => NULL, 'remember_token' => NULL, 'confirmed' => TRUE, 'admin' => starts_with($username, 'admin')]); } } // User::create([ // 'id' => 1, // 'username' => 'tonetlds', // 'email' => '*****@*****.**', // 'password' => Hash::make('254608'), // 'confirmation_code' => NULL, // 'remember_token' => NULL, // 'confirmed' => 1, // ]); }
function index() { $this->organizations = Organization::all(); }
/** * Display a listing of organizations * * @return Response */ public function index() { $organizations = Organization::all(); return View::make('organizations.index', compact('organizations')); }
function edit() { $this->user = User::find($this->params('id')); $this->organizations = Organization::all(); }
/** * Manages all school registered * @before _secure, _school, _admin */ public function all() { $this->setSEO(array("title" => "All Schools")); $view = $this->getActionView(); $limit = RequestMethods::get("limit", 10); $page = RequestMethods::get("page", 1); $organizations = Organization::all(array(), array("name", "user_id", "created"), "created", "desc", $limit, $page); $view->set("organizations", $organizations); }
function add() { $this->organizations = Organization::all(); }
public function popularPackages() { $this->seo(array("title" => "Popular Packages", "view" => $this->getLayoutView())); $view = $this->getActionView(); $organizations = Organization::all(array("live = ?" => true), array("id", "name")); $limit = RequestMethods::get("limit", 10); $page = RequestMethods::get("page", 1); $packages = Package::all(array("live = ?" => 1), array("title", "organization_id", "charge", "id"), "created", "desc", $limit, $page); $total = (int) Package::count(array("live = ?" => 1)); $results = array(); foreach ($packages as $p) { $data = array("title" => $p->title, "lab" => $organizations[$p->organization_id]->name, "lab_id" => $p->organization_id, "charge" => $p->charge, "id" => $p->id); $results[] = ArrayMethods::toObject($data); } $view->set("packages", $results)->set("total", $total); }
$credentials['email'] = Input::get('email'); } return Password::reset($credentials, function ($user, $password) { $user->setPassword($password); $user->save(); return Redirect::route('login'); }); }); // JSON VIEWS Route::get('{object_name}/json', array('as' => 'json', function ($object_name) { switch ($object_name) { case 'users': $object = User::all(); break; case 'organizations': $object = Organization::all(); break; default: $object = ''; } return Response::json($object); })); Route::get('{object_name}/{id}/json', array('as' => 'json', function ($object_name, $id) { switch ($object_name) { case 'user': $object = User::find($id); break; case 'organization': $object = Organization::find($id); break; default:
public function generateBills() { $orgs = Organization::all(["live = ?" => true]); foreach ($orgs as $org) { $imp_cost = 0; $click_cost = 0; $month_ini = new DateTime("first day of last month"); $month_end = new DateTime("last day of last month"); $start = $month_ini->format('Y-m-d'); $end = $month_end->format('Y-m-d'); $dateQuery = Utils::dateQuery(['start' => $start, 'end' => $end]); // find advertiser performances to get clicks and impressions $performances = \Performance::overall($dateQuery, User::all(['org_id' => $org->_id, 'type' => 'advertiser'], ['_id'])); $clicks = $performances['total_clicks']; if ($clicks > 1000) { $click_cost = 0.001 * $clicks * $org->meta["bill"]["tcc"]; } $impressions = $performances['total_impressions']; if ($impressions > 100000) { $imp_cost = 0.001 * 0.001 * $impressions * $org->meta["bill"]["mic"]; } $total = $click_cost + $imp_cost; $bill = new Bill(["org_id" => $org->id, "impressions" => $impressions, "clicks" => $clicks, "mic" => $org->meta["bill"]["mic"], "tcc" => $org->meta["bill"]["tcc"], "start" => $start, "end" => $end, "amount" => $total, "live" => false, "created" => Db::time('-1 day')]); if ($total > 1) { $bill->save(); $user = User::first(["org_id = ?" => $org->id, "type = ?" => "admin"]); Mail::send(['user' => $user, 'bill' => $bill, 'template' => 'adminBilling', 'subject' => 'Billing at vNative', 'click_cost' => $click_cost, 'imp_cost' => $imp_cost, 'org' => $org]); } } }