本文整理汇总了PHP中Contact::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::find方法的具体用法?PHP Contact::find怎么用?PHP Contact::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$umsg = Contact::find(array("co_status = 0"));
$this->view->umsg = $umsg;
$rmsg = Contact::find(array("co_status = 1"));
$this->view->rmsg = $rmsg;
}
示例2: getContact
public function getContact($id)
{
$contact = Contact::find($id);
if (!$contact) {
return Redirect::to('admin/contact');
}
$this->layout->body = View::make('admin.contact')->with('contact', $contact);
}
示例3: testRemove
public function testRemove()
{
$first = Contact::first();
$id = $first->id;
$crawler = $this->client->request('DELETE', '/api/contact/' . $id);
$this->assertTrue($this->client->getResponse()->isOk());
$first = Contact::find($id);
$this->assertTrue($first == null);
}
示例4: saveModel
protected function saveModel($contact = false)
{
if (Input::get('id')) {
$contact = Contact::find(Input::get('id'));
}
if (!$contact) {
$contact = new Contact();
}
$contact->function = Input::get('function');
$contact->first_name = Input::get('first_name');
$contact->last_name = Input::get('last_name');
$contact->references = Input::get('references');
$contact->notes = Input::get('notes');
$address = $contact->address()->first() ?: new Address();
$address_input = Input::get('address');
$country = Country::where('name', Input::get('country'))->first();
if ($country) {
$address->country()->associate($country);
}
$address->address = isset($address_input['address']) ? $address_input['address'] : '';
$address->postal_code = isset($address_input['postal_code']) ? $address_input['postal_code'] : '';
$address->city = isset($address_input['city']) ? $address_input['city'] : '';
$address->state_province = isset($address_input['state_province']) ? $address_input['state_province'] : '';
$address->phone = isset($address_input['phone']) ? $address_input['phone'] : '';
$address->fax = isset($address_input['fax']) ? $address_input['fax'] : '';
$address->email = isset($address_input['email']) ? $address_input['email'] : '';
$address->website = isset($address_input['website']) ? $address_input['website'] : '';
$address->save();
$contact->address()->associate($address);
$contact->save();
$parentQuery = Input::get('parent_model');
if (!empty($parentQuery)) {
$parentModel = null;
switch ($parentQuery) {
case 'events':
$relation = 'events';
$parentModel = 'Events';
break;
case 'company':
$relation = 'companies';
$parentModel = 'Company';
break;
case 'venue':
$relation = 'venues';
$parentModel = 'Venue';
break;
default:
break;
}
if (!empty($parentModel)) {
$contact->{$relation}()->detach($parentModel::find(Input::get('parent_id')));
$contact->{$relation}()->attach($parentModel::find(Input::get('parent_id')));
}
}
return $contact;
}
示例5: _conditions
private function _conditions($offset, $is_visibled)
{
$columns = array(array('key' => 'name', 'title' => '稱呼', 'sql' => 'name LIKE ?'), array('key' => 'email', 'title' => 'E-Mail', 'sql' => 'email LIKE ?'), array('key' => 'message', 'title' => '留言', 'sql' => 'message LIKE ?'), array('key' => 'ip', 'title' => 'IP', 'sql' => 'ip LIKE ?'));
$configs = array('admin', $this->get_class(), '%s');
$conditions = conditions($columns, $configs);
Contact::addConditions($conditions, 'is_visibled = ?', $is_visibled);
$limit = 25;
$total = Contact::count(array('conditions' => $conditions));
$offset = $offset < $total ? $offset : 0;
$this->load->library('pagination');
$pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 5, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li>', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li>', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li>', 'next_tag_close' => '</li>', 'last_tag_open' => '<li>', 'last_tag_close' => '</li>'), $configs))->create_links();
$contacts = Contact::find('all', array('offset' => $offset, 'limit' => $limit, 'conditions' => $conditions));
return array('contacts' => $contacts, 'pagination' => $pagination, 'columns' => $columns);
}
示例6: update
public function update($id)
{
$input = Input::all();
$validator = Validator::make($input, Contact::$rules);
if ($validator->fails()) {
return Response::json(["status" => "FAIL", "errors" => $validator->messages()]);
}
// Validation passed
$obj = Contact::find($id);
$obj->name = $input['name'];
$obj->email = $input['email'];
$obj->phone = $input['phone'];
$obj->save();
return Response::json(["status" => "OK"]);
}
示例7: buddy_action
/**
* Controller for all buddy related action.
*
* The following actions are supported:
* - "add" to add a user to the current user's buddy list
* - "remove" to remove a user from the current user's buddy list
*
* @param String $action The action to be executed
*/
public function buddy_action($action = 'add')
{
$username = Request::username('username');
if ($action === 'add' && $username !== null) {
if (Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => User::findByUsername($username)->id))->store()) {
PageLayout::postMessage(MessageBox::success(_('Der Benutzer wurde zu Ihren Kontakten hinzugefügt.')));
}
} elseif ($action === 'remove' && $username !== null) {
$contact = Contact::find(array(User::findCurrent()->id, User::findByUsername($username)->id));
if ($contact && $contact->delete()) {
PageLayout::postMessage(MessageBox::success(_('Der Benutzer gehört nicht mehr zu Ihren Kontakten.')));
}
}
$this->redirect('online');
}
示例8: testDelete
/**
* @depends testRelations
*/
public function testDelete($contact)
{
$cid = $contact->id;
$uid = $contact->user_id;
$new_contact = new Contact();
$new_user = new User();
$this->assertEquals($cid, $new_contact->find($cid)->id);
$this->assertEquals($uid, $new_user->eq('id', $uid)->find()->id);
$this->assertTrue($contact->user->delete());
$this->assertTrue($contact->delete());
$new_contact = new Contact();
$new_user = new User();
$this->assertFalse($new_contact->eq('id', $cid)->find());
$this->assertFalse($new_user->find($uid));
}
示例9: executeEmails
public function executeEmails()
{
$pools = $this->getTargetEmails();
if (!$pools) {
return;
}
foreach ($pools as $pool) {
$trysending = true;
$contact = Contact::find($pool->contact_id);
if ($contact->templateExist($pool->template_id)) {
$templateid = $contact->getAvalaibleTemplate();
if ($templateid == 0) {
//if template for send not exist disactivated contact
$trysending = false;
$contact->saveHistory("all have been sent", $pool->member_id, $pool->template_id);
$contact->active = 0;
$contact->save();
} else {
//try to send another template
$contact->saveHistory("sendanother", $pool->member_id, $pool->template_id);
$pool->template_id = $templateid;
$pool->save();
}
}
if ($trysending) {
if (EmailSchedullerPool::sendmail($pool->member_id, $pool->contact_id, $pool->template_id)) {
if ($contact->email_sent == "" || $contact->email_sent == 0) {
$contact->email_sent = $pool->template_id;
} else {
$contact->email_sent = $contact->email_sent . "," . $pool->template_id;
}
$contact->save();
$contact->saveHistory("success", $pool->member_id, $pool->template_id);
$newtemplate = $contact->getAvalaibleTemplate();
if ($newtemplate) {
$contact->insertPoolingSchedule($contact->id, $contact->user_id, $newtemplate);
} else {
$contact->saveHistory("all have been sent", $pool->member_id, $pool->template_id);
$contact->active = 0;
$contact->save();
}
$pool->delete();
} else {
//ARBUD : retry sending email 3 times
}
}
}
}
示例10: postEdit
public function postEdit($id = null)
{
$validator = Validator::make(Input::all(), Contact::$rulesEdit);
$data = Input::all();
$contact = Contact::find($id);
if (is_null($contact)) {
App::abort(404);
}
if ($validator->passes()) {
$contact->fill($data);
$contact->birthdate = date("Y-m-d", strtotime(Input::get('birthdate')));
$contact->save();
return Redirect::to(Input::get('url') . '#' . $contact->id)->with('confirmation', '¡Los datos de ' . $contact->fullname() . ' fueron actualizados!');
} else {
// validation has failed, display error messages
return Redirect::to(Input::get('url') . '#edit' . $contact->id)->with('message', 'Debes corregir los siguientes campos:')->withErrors($validator)->withInput();
}
}
示例11: saveModel
protected function saveModel($venue = false)
{
if (Input::get('id')) {
$venue = Venue::find(Input::get('id'));
}
if (!$venue) {
$venue = new Venue();
}
$venue->name = Input::get('name');
$venue->indoor_or_outdoor = Input::get('indoor_or_outdoor');
$venue->name_of_hall = Input::get('name_of_hall');
$venue->capacity = Input::get('capacity');
$venue->dimension_height = Input::get('dimension_height');
$venue->dimension_width = Input::get('dimension_width');
$venue->dimension_length = Input::get('dimension_length');
$venue->rigging_capacity = Input::get('rigging_capacity');
$venue->notes = Input::get('notes');
$address = $venue->address()->first() ?: new Address();
$country = Country::where('name', Input::get('country'))->first();
$address->country()->associate($country);
$address->address = Input::get('address_address');
$address->postal_code = Input::get('address_postal_code');
$address->city = Input::get('address_city');
$address->state_province = Input::get('address_state_province');
$address->phone = Input::get('address_phone');
$address->fax = Input::get('address_fax');
$address->email = Input::get('address_email');
$address->website = Input::get('address_website');
$address->save();
$venue->address()->associate($address);
$venue->save();
$venue->save();
if (Input::get('company_id')) {
$venue->companies()->detach(Company::find(Input::get('company_id')));
$venue->companies()->attach(Company::find(Input::get('company_id')));
}
if (Input::get('contact_id')) {
$venue->contacts()->detach(Contact::find(Input::get('contact_id')));
$venue->contacts()->attach(Contact::find(Input::get('contact_id')));
}
return $venue;
}
示例12: saveModel
protected function saveModel($company = false)
{
if (Input::get('id')) {
$company = Company::find(Input::get('id'));
}
if (!$company) {
$company = new Company();
}
$company->name = Input::get('name');
$company->type = Input::get('type');
$company->references = Input::get('references');
$company->bank_details = Input::get('bank_details');
$company->tax_number = Input::get('tax_number');
$company->notes = Input::get('notes');
$address = $company->address()->first() ?: new Address();
$country = Country::where('id', Input::get('country'))->first();
$address->country()->associate($country);
$address->address = Input::get('address_address');
$address->postal_code = Input::get('address_postal_code');
$address->city = Input::get('address_city');
$address->state_province = Input::get('address_state_province');
$address->phone = Input::get('address_phone');
$address->fax = Input::get('address_fax');
$address->email = Input::get('address_email');
$address->website = Input::get('address_website');
$address->save();
$company->address()->associate($address);
$company->save();
if (Input::get('venue_id')) {
$company->venues()->detach(Venue::find(Input::get('venue_id')));
$company->venues()->attach(Venue::find(Input::get('venue_id')));
}
if (Input::get('contact_id')) {
$company->contacts()->detach(Contact::find(Input::get('contact_id')));
$company->contacts()->attach(Contact::find(Input::get('contact_id')));
}
if (Input::get('event_id')) {
$company->events()->detach(Events::find(Input::get('event_id')));
$company->events()->attach(Events::find(Input::get('event_id')));
}
return $company;
}
示例13: indexAction
public function indexAction()
{
$auth = $this->session->get('auth');
$this->view->name = $auth[name];
$date = date('Y-m-d');
echo $date;
$orders = Orders::find("o_delivery = 0");
$nosorders = count($orders);
$contact = Contact::find("co_status = 0");
$noscontact = count($contact);
$users = Userdetails::find();
$nosusers = count($users);
$result = Orders::sum(array('column' => 'o_price', "conditions" => "o_date = :date:", "bind" => array("date" => $date)));
/*$phql="SELECT SUM(o_price) AS costs FROM Orders where o_date='2015-12-11'";
$result = $this->modelsManager->executeQuery($phql);*/
$this->view->nosorders = $nosorders;
$this->view->noscontact = $noscontact;
$this->view->nosusers = $nosusers;
$this->view->nossale = $result;
}
示例14: sendEmailpost
public function sendEmailpost()
{
$rules = ['contact_id' => 'required', 'template_id' => 'required'];
$validator = Validator::make(Input::all(), $rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::back()->withErrors($validator);
} else {
$contact = Contact::find(Input::get('contact_id'));
if (!$contact->active) {
return Redirect::back()->with('message', 'Kontak tidak aktif');
}
$memberid = Auth::user()->id;
$contactid = Input::get('contact_id');
$templateid = Input::get('template_id');
$issent = EmailSchedullerPool::sendManualEmail($memberid, $contactid, $templateid);
if ($issent) {
return Redirect::to(Auth::user()->roleString() . '/outbox')->with('message', 'Email berhasil dikirim.');
}
return Redirect::back()->with('message', 'Email tidak dapat dikirim, mohon mencoba kembali.');
}
}
示例15: d
public function d($id)
{
if (Input::get('remarks_hid') == "" || Input::get('remarks_hid') == "Write remarks here.") {
return Redirect::route('contact.dt', $id)->withInput()->with('class', 'error')->with('message', 'Write a *remarks first.');
}
$contact = Contact::find($id);
$gettime = time() - 14400;
$datetime_now = date("H:i:s", $gettime);
if (is_null($contact)) {
$class = 'error';
$message = 'Record does not exist.';
} else {
$contact->remarks = strtoupper(Input::get('remarks_hid'));
$contact->status = 3;
$contact->notif = 1;
$contact->notif_dt = date('Y-m-d') . ' ' . $datetime_now;
$contact->approved_by = Auth::id();
$contact->save();
$contact_person = DB::table('contacts')->select('id', 'fullname', 'created_by')->where('id', $id)->first();
DB::table('contact_status')->where('contact_id', $id)->where('access', 1)->update(array('access' => 2));
DB::table('contact_status')->insert(array(['contact_id' => $contact_person->id, 'user_id' => Auth::id(), 'update' => 'DENIED THE REQUEST FOR' . ' ' . $contact_person->fullname, 'created_by' => $contact_person->created_by, 'created_at' => date('Y-m-d') . ' ' . $datetime_now, 'access' => 3]));
$class = 'success';
$message = 'Record successfully Denied.';
}
return Redirect::route('contact.ra')->with('class', $class)->with('message', $message);
}