public function testValidCreate() { $faker = Factory::create(); $name = $faker->name; Artisan::call('contact:create', ['name' => $name, 'reference' => $faker->domainWord, 'account_id' => Account::getSystemAccount()->id, 'enabled' => $faker->boolean(), 'email' => $faker->email, 'api_host' => $faker->url]); $this->assertContains('The contact has been created', Artisan::output()); Contact::where('name', $name)->forceDelete(); }
/** * @param $name * @return Netblock|null */ private function findByContactName($name) { $netblock = null; $contact = Contact::where('name', "=", $this->option('filter'))->first(); if (null !== $contact) { $netblock = $contact->netblocks->first(); } return $netblock; }
/** * @param $name * * @return $collection \Illuminate\Support\Collection||null */ private function findByContactName($name) { $collection = null; $contact = Contact::where('name', '=', $name)->first(); if (null !== $contact) { $collection = $contact->netblocks; //->first(); } return $collection; }
static function byCode($reference) { $contact = Contact::where('reference', '=', $reference)->where('enabled', '=', true)->take(1)->get(); if (isset($contact[0])) { return $contact[0]; } elseif (class_exists('AbuseIO::Custom::FindContact') === true && is_callable('\\AbuseIO\\Custom\\FindContact->byReference') === true) { // Call custom function } else { return FindContact::undefined(); } }
/** * Process datatables ajax request. * * @return \Illuminate\Http\JsonResponse */ public function search() { $auth_account = $this->auth_user->account; if ($auth_account->isSystemAccount()) { $contacts = Contact::all(); } else { $contacts = Contact::where('account_id', '=', $auth_account->id); } return Datatables::of($contacts)->addColumn('actions', function ($contact) { $actions = Form::open(['route' => ['admin.contacts.destroy', $contact->id], 'method' => 'DELETE', 'class' => 'form-inline']); $actions .= ' <a href="contacts/' . $contact->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-eye-open"></i> ' . trans('misc.button.show') . '</a> '; $actions .= ' <a href="contacts/' . $contact->id . '/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> ' . trans('misc.button.edit') . '</a> '; $actions .= Form::button('<i class="glyphicon glyphicon-remove"></i> ' . trans('misc.button.delete'), ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']); $actions .= Form::close(); return $actions; })->editColumn('account_id', function ($contact) { return $contact->account->name; })->editColumn('auto_notify', function ($contact) { return empty($contact->auto_notify) ? trans('misc.manual') : trans('misc.automatic'); })->make(true); }
/** * Return contact by Code * * @param string $id contact reference * @return object */ public static function byId($id) { // If local lookups are not preferred, then do the remote lookup first if (config('main.external.prefer_local') === false) { $findContact = FindContact::getExternalContact('id', $id); if (!empty($findContact)) { return $findContact; } } // Do a local lookup $result = Contact::where('reference', '=', $id)->where('enabled', '=', true)->take(1)->get(); if (isset($result[0])) { return $result[0]; } // Do a remote lookup, if local lookups are preferred. Else skip this as this was already done. if (config('main.external.prefer_local') === true) { $findContact = FindContact::getExternalContact('id', $id); if (!empty($findContact)) { return $findContact; } } return FindContact::undefined(); }
/** * {@inherit docs}. */ protected function getCollectionWithArguments() { return Contact::where('name', 'like', '%' . $this->argument('contact') . '%')->orWhere('id', $this->argument('contact')); }
/** * {@inheritdoc}. */ protected function findWithCondition($filter) { return Contact::where('name', 'like', "%{$filter}%")->get(); }
/** * Return contact by Code * @param string $reference * @return object */ public static function byId($id) { $result = Contact::where('reference', '=', $id)->where('enabled', '=', true)->take(1)->get(); if (isset($result[0])) { return $result[0]; } $findContact = FindContact::getExternalResolver('id', $id); if (!empty($findContact)) { return $findContact; } return FindContact::undefined(); }
public function testModelFactory() { $contact = factory(Contact::class)->create(); $contactFromDB = Contact::where('name', $contact->name)->first(); $this->assertEquals($contact->name, $contactFromDB->name); }