public static function updateGroups(Request $request) { $titles = $request::get('title'); $ids = $request::get('id'); $deleteId = $request::get('delete'); $newtitle = $request::get('newtitle'); $i = 0; if ($ids) { foreach ($ids as $id) { $group = Organization::find($id); $group->title = $titles[$i]; if (isset($deleteId[$i]) && $deleteId[$i] == $id) { $group->delete(); } else { $group->save(); } $i++; } } if ($newtitle) { $group = new Organization(); $group->title = $newtitle; $group->save(); } return true; }
/** * Store a newly created resource in storage. * * @param Organization $org; * @param GymRequest $request * @return \Illuminate\Http\Response */ public function store(Organization $org, GymRequest $request) { $gym = new Gym($request->all()); $org->gyms()->save($gym); $gymRoleOwner = new GymRole(['name' => 'Owner', 'description' => 'Gym owner.']); $gymRoleEmployee = new GymRole(['name' => 'Employee', 'description' => 'Gym employee.']); $gymRoleMember = new GymRole(['name' => 'Member', 'description' => 'Gym member.']); $gym->roles()->save($gymRoleOwner); $gym->roles()->save($gymRoleEmployee); $gym->roles()->save($gymRoleMember); //$gymPermission = new GymPermission(['name' => '']) //todo: do i set a role for the creator automatically? //\Auth::user()->gymRoles()->save($gymRoleOwner); return redirect()->action('OrganizationsController@show', [$org]); }
public function edit($id) { $request = Request::with(['equipment', 'area', 'location', 'category', 'uploads', 'approvers', 'status', 'actions' => function ($query) { $query->orderBy('created_at', 'desc'); }, 'actions.submitted', 'comments.author' => function ($query) { $query->orderBy('created_at', 'asc'); }])->find($id); if (is_null($request)) { return view('security.not-found'); } $data['request'] = $request; $data['areas'] = Area::all(['id', 'name']); $data['organizations'] = Organization::all(); $data['categories'] = Category::all(['id', 'name']); $data['locations'] = Location::all(['id', 'name']); $data['approvers'] = Approval::getRecent($id); $data['hasApproved'] = Approval::hasApproved($id)->exists(); if ($request->Status->name == 'Approved') { return view('request.view', $data); } if ($request->submitted_by != Auth::User()->id && !Auth::User()->hasRole(['administrator', 'approver'])) { return view('security.401'); } return view('request.edit', $data); }
public function Ostore(Request $request, $id) { $this->validate($request, ['title' => 'required', 'event_due' => 'required']); $event = new Event($request->all()); Organization::findOrFail($id)->events()->save($event); return redirect('/home/events'); }
function checkOrganization($name) { $organization = Organization::OfName($name)->first(); if (empty($organization)) { throw new Exception("Organization doesnt exists"); } }
public function Ostore($id, PostRequest $request) { $post = new Post($request->all()); $organization = Organization::findOrFail($id); $organization->posts()->save($post); return redirect('/home/posts'); }
/** * Run the users seeds. * * @return void */ public function run() { DB::table('organizations')->delete(); $statement = "ALTER TABLE organizations AUTO_INCREMENT = 1;"; DB::unprepared($statement); Organization::create(['uuid' => uniqid(), 'name' => 'Gorilla LTD', 'address' => '61 cours du médoc', 'address_comp' => 'appt 22 bat B', 'user_id' => 1]); }
/** * A basic test example. * * @return void */ public function testCreateRequest() { //$this->assertTrue(true); $testData = ["org_name" => "Paradise Island", "daughters" => [["org_name" => "Banana tree", "daughters" => [["org_name" => "Yellow Banana"], ["org_name" => "Brown Banana"], ["org_name" => "Green Banana"]]]]]; //making store request $this->post('api/organizations/store', $testData)->seeJson(["success" => true]); //chcking if they exist in DB $this->seeInDatabase('organizations', ['org_name' => "Paradise Island"]); $this->seeInDatabase('organizations', ['org_name' => 'Banana tree']); $this->seeInDatabase('organizations', ['org_name' => 'Yellow Banana']); $this->seeInDatabase('organizations', ['org_name' => 'Brown Banana']); $this->seeInDatabase('organizations', ['org_name' => 'Green Banana']); $org = Organization::where('org_name', "Banana tree")->first(); $org->load('parent', 'daughters'); //checking relations $this->assertEquals("Paradise Island", $org->parent->org_name); $this->assertEquals("Yellow Banana", $org->daughters[0]->org_name); $this->assertEquals("Brown Banana", $org->daughters[1]->org_name); $this->assertEquals("Green Banana", $org->daughters[2]->org_name); //making get organization request, and expecting exact json //I need organization details to insert correct creation time to json $org1 = Organization::where('org_name', "Paradise Island")->first(); $org2 = Organization::where('org_name', "Banana tree")->first(); $org3 = Organization::where('org_name', "Yellow Banana")->first(); $org4 = Organization::where('org_name', "Brown Banana")->first(); $org5 = Organization::where('org_name', "Green Banana")->first(); $expected = ["success" => true, "pipedrive_format" => [["type" => "parent", "rel_owner_org_id" => ["name" => "Paradise Island", "id" => "1"], "rel_linked_org_id" => ["name" => "Banana tree", "id" => "2"], "add_time" => $org2->created_at->toDateTimeString(), "calculated_type" => "parent"], ["type" => "parent", "rel_owner_org_id" => ["name" => "Banana tree", "id" => "2"], "rel_linked_org_id" => ["name" => "Yellow Banana", "id" => "3"], "add_time" => $org3->created_at->toDateTimeString(), "calculated_type" => "daughter"], ["type" => "parent", "rel_owner_org_id" => ["name" => "Banana tree", "id" => "2"], "rel_linked_org_id" => ["name" => "Brown Banana", "id" => "4"], "add_time" => $org4->created_at->toDateTimeString(), "calculated_type" => "daughter"], ["type" => "parent", "rel_owner_org_id" => ["name" => "Banana tree", "id" => "2"], "rel_linked_org_id" => ["name" => "Green Banana", "id" => "5"], "add_time" => $org5->created_at->toDateTimeString(), "calculated_type" => "daughter"]]]; $this->get("api/organizations/" . $org->id)->seeJsonEquals($expected); //making delete request $this->delete('api/organizations')->seeJson(["success" => true]); }
public function destroy($id) { if (Gate::denies('adminOnly')) { abort(403); } return Organization::destroy($id); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $organization = Organization::findOrFail($id); $name = $organization->name; $organization->delete(); session()->flash('flash_message', "The organization \"{$name}\" has been removed."); return redirect('organizations'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { try { return view('credential.edit', ['credential' => Credential::findOrFail($id), 'organizations' => Organization::all()]); } catch (\Exception $e) { return redirect()->back()->withError('Could not locate credential.'); } }
/** * Удаление типа * * @param Type $type * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function delete(Type $type) { if (Organization::where('type_id', $type->id)->exists()) { dd('Есть организации с таким типом'); } $type->delete(); return redirect()->route('admin::type'); }
/** * Удаление статуса * * @param Status $status * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function delete(Status $status) { if (Organization::where('status_id', $status->id)->exists()) { dd('Есть организации с таким статусом'); } $status->delete(); return redirect()->route('admin::status'); }
/** * Удаление ОПФ * * @param Opf $opf * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function delete(Opf $opf) { if (Organization::where('opf_id', $opf->id)->exists()) { dd('Есть организации с таким ОПФ'); } $opf->delete(); return redirect()->route('admin::opf'); }
/** * Удаление города * * @param City $city * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function delete(City $city) { if (Organization::where('city_id', $city->id)->exists()) { dd('Есть организации с таким городом'); } $city->delete(); return redirect()->route('admin::city'); }
function register($input) { foreach ($input as $key => $value) { $this->checkEmpty($key, $value); } $user = User::create(['first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'email' => $input['email'], 'password' => Hash::make($input['password'])]); $organization = Organization::OfName($input['organization_name'])->first(); Member::create(['user_id' => $user->id, 'organization_id' => $organization->id]); }
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]); }
public function show(Request $request, $id = 0) { $roles = $request->user()->roles; if ($id == 0 && !$roles->isEmpty()) { $id = $roles[0]->organization_id; } if ($roles->isEmpty()) { return redirect()->route('newOrganizationForm'); } $organization = Organization::find($id); return view('organizations.view', ['organization' => $organization, 'roles' => $roles]); }
/** * Execute the job. * * @param FlatCmService $service * @param WebsiteRepositoryInterface $websiteRepository */ public function handle(FlatCmService $service, WebsiteRepositoryInterface $websiteRepository) { if ($service->process($this->identifier, $this->username, $this->email, $this->password)) { $website = $websiteRepository->create(['identifier' => $this->identifier, 'username' => $this->username, 'email' => $this->email, 'is_active' => true, 'url' => 'http://' . $this->identifier . '.' . env('CMS_BASE_URL')]); $organization = Organization::findOrFail($this->organization_id); $website->organization()->associate($organization); $website->save(); //fire event } else { //fire event } }
protected static function updateDB($data) { foreach ($data as $title) { if ($title['STUDENT ID'] != '') { //creating or updating districts $DDBNNN = preg_split('/(?<=[0-9])(?=[a-z]+)/i', $title['DDBNNN']); $district = District::firstOrCreate(['code' => $DDBNNN[0], 'system_id' => 1]); $district->code = $DDBNNN[0]; $district->system_id = 1; $district->title = 'District ' . $DDBNNN[0]; $district->save(); $organization = Organization::where(['code' => $DDBNNN[1]])->with(array('districts' => function ($query) use($district) { $query->where('district_id', $district->id); }))->first(); if (is_null($organization)) { // TODO figure out if this can be replaced with a firstOrCreate; $organization = new Organization(); } $organization->code = $DDBNNN[1]; $organization->title = $DDBNNN[1]; $organization->save(); if (!$organization->districts->contains($district->id)) { $organization->districts()->attach($district->id); } $user = User::firstOrCreate(['student_id' => $title['STUDENT ID']]); $user->student_id = $title['STUDENT ID']; $user->first_name = $title['FIRST NAME']; $user->last_name = $title['LAST NAME']; $user->sex = $title['SEX']; $user->dob = $title['BIRTH DT']; $user->save(); } } $notifier = new Notifier(); $notifier->to = Auth::user()->email; $notifier->subject = "Your import is completed at " . date('m-d-Y h:i:s A'); $notifier->template = "emails.import"; $notifier->attachData(['user' => Auth::user()]); $notifier->send(); }
/** * Save */ public function save($supplier = null, $data = null) { DB::transaction(function () use(&$data, &$supplier) { if (is_null($supplier)) { $org = Organization::create($data['info']); $supplier = $org->supplier()->create($data); } else { $supplier->info->fill($data['info'])->save(); $supplier->fill($data)->save(); } }); return $this->getById($supplier->id); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('organizations')->truncate(); $faker = Faker::create(); Organization::create(['name' => 'GLOBALFOUNDRIES']); /* foreach(range(1,30) as $index) { Organization::create([ 'name' => $faker->company, ]); } */ }
public function testCreateRelationsEndpoint() { $this->delete('/relations'); $data = array("org_name" => "Paradise Island", "daughters" => array(0 => array("org_name" => "Banana tree", "daughters" => array(0 => array("org_name" => "Yellow Banana"), 1 => array("org_name" => "Red Banana"), 2 => array("org_name" => "Green Banana"))))); $this->post('/relations', $data)->seeJson(['success' => true]); $this->assertEquals(5, Organization::get()->count()); $this->assertEquals(4, Relation::get()->count()); $this->post('/relations')->seeJson(['success' => false, 'error' => 'No request parameters']); $this->delete('/relations'); $data = array("org_name" => "Paradise Island", "daughters" => array(0 => array("org_name" => "Banana tree", "daughters" => array(0 => array("org_name" => "Yellow Banana"), 1 => array("org_name" => "Yellow Banana"), 2 => array("org_name" => "Green Banana"))))); $this->post('/relations', $data)->seeJson(['success' => false])->see('Duplicate organization name'); $this->assertEquals(4, Organization::get()->count()); $this->assertEquals(3, Relation::get()->count()); }
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); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request, $orgId) { $organization = \App\Organization::findOrFail($orgId); $restaurants = Restaurant::orderBy('name')->get(); foreach ($restaurants as $restaurant) { $restaurant->is_used = false; if (count($organization->restaurants) > 0) { foreach ($organization->restaurants as $orgRest) { if ($orgRest->id == $restaurant->id) { $restaurant->is_used = true; } } } } return view('restaurants.list', ['restaurants' => $restaurants, 'organization' => $organization]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(\Request $request) { if ($request::isMethod('post')) { $validator = Validator::make(Input::all(), District::$groupUpdateRules); //if ($validator->passes()) { @TODO fix this to accept array in Group::$groupUpdateRules if ($validator->passes()) { if (District::updateGroups($request)) { return Redirect::to('/districts')->with('message', 'The following errors occurred')->withErrors('Update success')->with('flag', 'success'); } return Redirect::to('/districts')->with('message', 'The following errors occurred')->withErrors('Update failed')->with('flag', 'danger'); } return Redirect::to('/districts')->with('message', 'The following errors occurred')->withErrors($validator)->withInput()->with('flag', 'danger'); } $allorganizations = Organization::all(); $data = District::with('organization')->paginate(25); return view('districts/all', compact('data', 'allorganizations')); }
/** * * Activate CMS INSTANCE * @param WebsiteRequest $request * @param FlatCmService $service * @param WebsiteRepositoryInterface $websiteRepository * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @internal param FlatCmService $service * @internal param WebsiteRepositoryInterface $websiteRepository */ public function store(WebsiteRequest $request, FlatCmService $service) { $identifier = str_slug($this->organization->name, "-"); $username = $request->get('username'); $email = $request->get('email'); $password = $request->get('password'); //$this->dispatch(new CreateWebsite($this->organization->id, $identifier, $username, $email, $password)); if ($service->process($identifier, $username, $email, $password)) { $website = Website::create(['identifier' => $identifier, 'username' => $username, 'email' => $email, 'is_active' => true, 'url' => 'http://' . $identifier . '.' . env('CMS_BASE_URL')]); $organization = Organization::findOrFail($this->organization->id); $website->organization()->associate($organization); $website->save(); Flash::success(Lang::get('website.create-success')); } else { Flash: error: Lang::get('website.create-failed'); } return redirect(action('WebsiteController@index')); }
public function run() { DB::table('users')->delete(); DB::table('child_guardian')->delete(); $jon = User::create(array("name" => "Jon Toshmatov", "first_name" => "Jon", "last_name" => "Toshmatov", "email" => "*****@*****.**", "password" => Hash::make("business"), "slug" => 'jon_slug', "student_id" => '*****@*****.**')); $arron = User::create(array("name" => "Arron Kallenberg", "first_name" => "Arron", "last_name" => "Kallenberg", "email" => "*****@*****.**", "password" => Hash::make("business"), "slug" => 'arron-kallenberg', "student_id" => '*****@*****.**')); // Create 5 Teachers for ($i = 1; $i < 5; $i++) { $teacher = User::create(array("name" => "teacher" . $i, "email" => "*****@*****.**" . $i, "password" => Hash::make("business"), "slug" => 'teacher_slug' . $i, "student_id" => 'teacher_id' . $i)); } // Create 5 Guardians for ($i = 1; $i < 5; $i++) { $guardian = User::create(array("name" => "parent" . $i, "email" => "*****@*****.**" . $i, "password" => Hash::make("business"), "slug" => 'parent_slug' . $i, "student_id" => 'guardian_id' . $i)); } // Create 5 Children for ($i = 1; $i < 5; $i++) { $child = User::create(array("name" => "child" . $i, "email" => "*****@*****.**" . $i, "password" => Hash::make("business"), "slug" => 'child_slug' . $i, "student_id" => 'child_id' . $i)); } DB::table('roles')->truncate(); $admin = Role::create(array("title" => "admin")); $principal = Role::create(array("title" => "principal")); $role_teacher = Role::create(array("title" => "teacher")); $role_student = Role::create(array("title" => "student")); $jon->role()->sync([$admin->id]); $arron->role()->sync([$admin->id]); DB::table('child_guardian')->insert(['guardian_id' => $guardian->id, 'child_id' => $child->id]); for ($i = 1; $i < 5; $i++) { $district = District::create(array("title" => "District " . $i, "description" => "District:" . $i . " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy tex ")); } for ($i = 1; $i < 5; $i++) { $organization = Organization::create(array("title" => "Organization " . $i, "description" => "School:" . $i . " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy tex ")); } DB::table('district_organization')->insert(['district_id' => $district->id, 'organization_id' => $organization->id]); for ($i = 1; $i < 5; $i++) { $class = Group::create(array("organization_id" => $organization->id, "title" => "Class " . $i, "description" => "Class:" . $i . " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy tex ")); } // Create pages for ($i = 1; $i < 5; $i++) { $page = \app\cmwn\Page::create(array("title" => "title" . $i, "description" => "description" . $i, "avatar" => "/img/avatar.png")); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->truncate(); DB::table('role_user')->truncate(); $faker = Faker::create(); $orgs = Organization::all()->lists('id')->toArray(); User::create(['name' => 'Christopher Carver', 'email' => '*****@*****.**', 'organization_id' => '1', 'password' => bcrypt('3l1t3')]); /* foreach(range(1,100) as $index) { $user = User::create([ 'name' => $faker->name, 'email' => $faker->email, 'organization_id' => $faker->randomElement($orgs), 'password' => str_random(10), 'remember_token' => str_random(10), ]); $user->attachRole(3); } */ User::find(1)->attachRole(1); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { if ($organization = Organization::where('userId', Auth::user()->id)->first()) { } else { $organization = new Organization(); $organization->userId = Auth::user()->id; } if ($request['brochure']) { $filepath = base_path() . "/public/uploads/" . $organization->brochure; is_file($filepath) ? file_exists($filepath) ? unlink($filepath) : " " : " "; $name = time() . "." . $request->file('brochure')->getClientOriginalExtension(); $dest = base_path() . "/public/uploads"; $request->file('brochure')->move($dest, $name); $organization->brochure = $name; } $organization->name = $request['name']; $organization->address = $request['address']; $organization->description = $request['description']; $organization->save(); \Session::flash('success_message', 'Your record has been updated'); return redirect('organization/edit'); }