本文整理汇总了PHP中Client::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::find方法的具体用法?PHP Client::find怎么用?PHP Client::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($id)
{
$delete = Client::find($id);
$delete->delete();
$data = array('clients' => Client::orderBy('id', 'desc')->get(), 'refresh' => true);
return View::make('clients.table', $data);
}
示例2: deleteUser
public function deleteUser($id)
{
$admin = Client::find($id);
Client::destroy($id);
Session::flash('flash_msg', "L'administrateur " . $admin->loginClient . " a bien été supprimé.");
Session::flash('flash_type', "warning");
return Redirect::to('/admin/users');
}
示例3: deleteUtilisateur
public function deleteUtilisateur($id)
{
$utilisateur = Client::find($id);
Client::destroy($id);
Session::flash('flash_msg', "L'utilisateur " . $utilisateur->prenomClient . " " . $utilisateur->nomClient . " a bien été supprimé.");
Session::flash('flash_type', "warning");
return Redirect::to('/admin/utilisateurs');
}
示例4: __construct
function __construct()
{
parent::__construct();
$this->view_data['core_settings'] = Setting::first();
if ($this->input->cookie('language') != "") {
$language = $this->input->cookie('language');
} else {
if (isset($this->view_data['language'])) {
$language = $this->view_data['language'];
} else {
if (!empty($this->view_data['core_settings']->language)) {
$language = $this->view_data['core_settings']->language;
} else {
$language = "english";
}
}
}
$this->lang->load('application', $language);
$this->lang->load('messages', $language);
$this->lang->load('event', $language);
$this->user = $this->session->userdata('user_id') ? User::find_by_id($this->session->userdata('user_id')) : FALSE;
$this->client = $this->session->userdata('client_id') ? Client::find_by_id($this->session->userdata('client_id')) : FALSE;
if ($this->client) {
$this->theme_view = 'application_client';
}
$this->view_data['datetime'] = date('Y-m-d H:i', time());
$this->view_data['sticky'] = Project::all(array('conditions' => 'sticky = 1'));
$this->view_data['quotations_new'] = Quote::find_by_sql("select count(id) as amount from quotations where status='New'");
if ($this->user || $this->client) {
$access = $this->user ? $this->user->access : $this->client->access;
$access = explode(",", $access);
if ($this->user) {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'main')));
$this->view_data['widgets'] = Module::find('all', array('conditions' => array('id in (?) AND type = ?', $access, 'widget')));
} else {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'client')));
}
if ($this->user) {
$update = User::find($this->user->id);
} else {
$update = Client::find($this->client->id);
}
$update->last_active = time();
$update->save();
if ($this->user) {
$this->view_data['user_online'] = User::all(array('conditions' => array('last_active+(30 * 60) > ? AND status = ?', time(), "active")));
$this->view_data['client_online'] = Client::all(array('conditions' => array('last_active+(30 * 60) > ? AND inactive = ?', time(), "0")));
}
$email = $this->user ? 'u' . $this->user->id : 'c' . $this->client->id;
$this->view_data['messages_new'] = Privatemessage::find_by_sql("select count(id) as amount from privatemessages where `status`='New' AND recipient = '" . $email . "'");
$this->view_data['tickets_new'] = Ticket::find_by_sql("select count(id) as amount from tickets where `status`='New'");
}
/*$this->load->database();
$sql = "select * FROM templates WHERE type='notes'";
$query = $this->db->query($sql); */
$this->view_data["note_templates"] = "";
//$query->result();
}
示例5: indexAction
public function indexAction()
{
$users = User::find(array('conditions' => 'idAccount = ?1', 'bind' => array(1 => $this->user->idAccount)));
$tvisits = Visittype::find(array('conditions' => 'idAccount = ?1', 'bind' => array(1 => $this->user->idAccount)));
$clients = Client::find(array('conditions' => 'idAccount = ?1', 'bind' => array(1 => $this->user->idAccount)));
$this->view->setVar('users', $users);
$this->view->setVar('tvisits', $tvisits);
$this->view->setVar('clients', $clients);
}
示例6: action_do_delete
public function action_do_delete($client_id)
{
$client = Client::find($client_id);
if (empty($client)) {
return Redirect::back();
}
$client->modpacks()->delete();
$client->delete();
Cache::forget('clients');
return Redirect::to('client/list')->with('success', 'Client deleted!');
}
示例7: postDelete
public function postDelete($client_id)
{
$client = Client::find($client_id);
if (empty($client)) {
return Redirect::to('client/list')->withErrors(new MessageBag(array('Client UUID not found')));
}
$client->modpacks()->sync(array());
$client->delete();
Cache::forget('clients');
return Redirect::to('client/list')->with('success', 'Client deleted!');
}
示例8: logout
function logout()
{
if ($this->user) {
$update = User::find($this->user->id);
} else {
$update = Client::find($this->client->id);
}
$update->last_active = 0;
$update->save();
User::logout();
redirect('login');
}
示例9: postUpdateclient
public function postUpdateclient()
{
$id = Input::get('id');
$client = Client::find($id);
$client->name = Input::get('name');
$client->email = Input::get('email');
$client->mobile = Input::get('mobile');
$client->city = Input::get('city');
$client->address1 = Input::get('address1');
$client->address2 = Input::get('address2');
$client->save();
return Response::json($client);
}
示例10: clientsAction
public function clientsAction($index = null)
{
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
if (!isset($index) || !is_numeric($index)) {
$clients = Client::find();
$this->view->setVars(array("model" => "Clients", "objects" => $clients));
$this->jquery->getOnClick(".edit", "Accueil/clients/", "#ajax-content");
} else {
$client = Client::findFirst($index);
$this->view->setVars(array("model" => "Clients", "client" => $client));
$this->view->pick("Accueil/client");
}
}
示例11: testFind
function testFind()
{
//Arrange
$id = null;
$client_name = "Nico";
$stylist_id = 1;
$test_client = new Client($id, $client_name, $stylist_id);
$test_client->save();
$client_name2 = "Al";
$stylist_id2 = 2;
$test_client2 = new Client($id, $client_name2, $stylist_id2);
$test_client2->save();
//Act
$result = Client::find($test_client->getId());
//Assert
$this->assertEquals($test_client, $result);
}
示例12: _checkUser
protected function _checkUser()
{
if (fnGet($this->input, 'access_token') == '') {
$this->_ajaxReturn(array('error_code' => '600020', 'error_msg' => '参数[access_token]不能为空'), 400);
}
// 设置当前用户和客户端
$this->session->setUser($user = new User())->setClient($client = new Client());
$passportConfig = $this->config->get("api.passport");
// 尝试从缓存获取 userInfo
if ($this->_userInfo = S($cacheKey = 'access_token_info.' . fnGet($this->input, 'access_token'))) {
$user->find(fnGet($this->_userInfo, 'user_id'));
$client->find(fnGet($this->_userInfo, 'client_id'));
return;
}
// 向 passport 请求 userInfo
$time = time();
$url = str_replace('internal-resource/user-info?', '', $passportConfig->passportUrl) . 'internal-resource/user-info';
$params = array('access_token' => fnGet($this->input, 'access_token'), 'app' => $passportConfig->passportApp, 'time' => $time);
$sign = md5(implode('', $params) . $passportConfig->passportSecret);
$params['sign'] = $sign;
$http = new HttpClient();
$response = $http->request($url, $params);
$data = json_decode($response, true);
if (fnGet($data, 'id')) {
//检测用户是否已经保存
$user->getByUsername($username = fnGet($data, 'username'));
if (!($userId = $user->getId()) || !$user->getData('passport_id') || $user->getData('mobile') != fnGet($data, 'mobile')) {
$user->addData(array('username' => $username, 'email' => fnGet($data, 'email'), 'mobile' => fnGet($data, 'mobile'), 'passport_id' => fnGet($data, 'passport_id'), 'avatar' => fnGet($data, 'avatar'), 'nickname' => fnGet($data, 'nickname')));
$user->save();
$userId = $user->getId();
}
//检测客户端是否已经保存
$client->getByAppId($appId = fnGet($data, 'client_info/id'));
if (!($clientId = $client->getId()) || $client->getScopes() != fnGet($data, 'client_info/scopes')) {
$client->addData(array('client' => $appId, 'name' => fnGet($data, 'client_info/name'), 'app_secret' => fnGet($data, 'client_info/secret'), 'developerurl' => fnGet($data, 'client_info/endpoint'), 'scopes' => fnGet($data, 'client_info/scopes')));
$client->save();
$clientId = $client->getId();
}
$this->_userInfo = array('user_id' => $userId, 'client_id' => $clientId, 'username' => $username, 'session_data' => fnGet($data, 'session_data'));
S($cacheKey, $this->_userInfo, 3600);
return;
}
$this->_ajaxReturn(array('error_code' => '600020', 'error_msg' => '用户无效'), 400);
}
示例13: validate_login
public static function validate_login($username, $password)
{
$user = User::find_by_username($username);
$client = Client::find_by_email_and_inactive($username, 0);
if ($user && $user->validate_password($password) && $user->status == 'active') {
User::login($user->id, 'user_id');
$update = User::find($user->id);
$update->last_login = time();
$update->save();
return $user;
} elseif ($client && $client->password == $password && $client->inactive == '0') {
User::login($client->id, 'client_id');
$update = Client::find($client->id);
$update->last_login = time();
$update->save();
return $client;
} else {
return FALSE;
}
}
示例14: test_client_find
function test_client_find()
{
//Arrange
$name = "Vidal Sassoon";
$test_stylist = new Stylist($name);
$test_stylist->save();
$name2 = "Sweeney Todd";
$test_stylist2 = new Stylist($name2);
$test_stylist2->save();
$name3 = "Mr. T";
$stylist_id = $test_stylist->getId();
$test_client = new Client($name3, $stylist_id, null);
$test_client->save();
$name4 = "Mrs. T";
$stylist_id2 = $test_stylist2->getId();
$test_client2 = new Client($name4, $stylist_id2, null);
$test_client2->save();
//Act
$result = Client::find($test_client->getId());
//Assert
$this->assertEquals($test_client, $result);
}
示例15: testShorthandForm
/**
* Test shorthand methods
*
* @return void
*/
public function testShorthandForm()
{
$fields = array('name', 'email', 'password:password', 'password2:password' => 'Confirm Password', 'user_source:select' => array('label' => 'How did you hear about us?', 'options' => array('friend' => 'From a friend', 'google' => 'Google search', 'other' => 'Other')));
$instance = Client::find(542);
$form = Squi\Form::make($fields, $instance);
$expected = $this->markup('shorthand_table');
$this->assertSame($expected, $form->render());
$form = Squi\Form::basic($fields, $instance);
$expected = $this->markup('shorthand_basic');
$this->assertSame($expected, $form->render());
$form = Squi\Form::table($fields, $instance);
$expected = $this->markup('shorthand_table');
$this->assertSame($expected, $form->render());
$form = Squi\Form::bootstrap($fields, $instance);
$expected = $this->markup('shorthand_bootstrap');
$this->assertSame($expected, $form->render());
$form = Squi\Form::of('Client', $instance, 'custom_field_method');
$expected = $this->markup('shorthand_custom');
$this->assertSame($expected, $form->render());
$form = Squi\Form::of($instance);
$expected = $this->markup('shorthand_model');
$this->assertSame($expected, $form->render());
}