本文整理汇总了PHP中app\models\Client类的典型用法代码示例。如果您正苦于以下问题:PHP Client类的具体用法?PHP Client怎么用?PHP Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postEditUser
public function postEditUser(Request $request, User $user, Client $client, CommonCode $cCode)
{
// $bool_include_password = $cCode->setCheckboxVar($request->include_password);
// $bool_include_email = $cCode->setCheckboxVar($request->include_email);
$validation_rules = $client->getValidationRulesEditUser();
// $validation_messages = $client->getValidationMessagesEditUser();
$this->validate($request, $validation_rules);
$arr_request = $client->getRequestArrayEditUser($request);
$user = $user->find(Auth::user()->id);
// $user = $cCode->getObject($arr_request, $user);
// $user->first_name = $arr_request->first_name;
// $user->last_name = $arr_request->last_name;
// $user->company = $arr_request->company;
// $arr_request = array();
// // transfer to new array, so as not to propagate teh password
// $arr_request['first_name'] = $request->first_name;
// $arr_request['last_name'] = $request->last_name;
// $arr_request['company'] = $request->company;
// $user->email = $arr_request['email'];
// $user->password = $arr_request['password'];
// $user->name = '';
// $user->save();
$client = $user->client;
// $client->cloaked_client_id = $client->getNewCloakedClientId($user->id);
// $client->user_id = $user->id;
$client->first_name = $arr_request['first_name'];
$client->last_name = $arr_request['last_name'];
$client->company = $arr_request['company'];
$client->client_url = $arr_request['client_url'];
$client->save();
// $user_id = $user->id;
$data = $client->getDataArrayPostEditUser($arr_request, $user->id, $this->cloakedClientId, $this->arr_logged_in_user);
return view('client/edit_user_results')->with('data', $data);
}
示例2: fakeClient
protected function fakeClient()
{
$fakeClient = new Client();
$fakeClient->serial_number = "C241874";
$fakeClient->primary_name = "Fake Client";
$fakeClient->client_type_id = $this->fakeClientType()->client_type_id;
$fakeClient->save();
return $fakeClient;
}
示例3: __construct
public function __construct(Role_user $role_user, User $user, Client $client, RoleHelper $roleHelper)
{
//next lines are temp code, until roles and auth implemented
// $this->arr_logged_in_user = array();
// $this->middleware('three_step:admin');
$this->middleware('auth');
if (Auth::check()) {
// $this->client_id = $user->find($user->id)->cloakedClientId();
$this->middleware('role:client');
$this->obj_logged_in_user = Auth::user();
$this->arr_logged_in_user = $client->getClientInfo(Auth::user()->id, Auth::user()->email);
// $this->arr_logged_in_client_info = $client->getClientInfo(Auth::user()->id);
}
// end if Auth::check()
}
示例4: save
public function save($publicId, $data)
{
if ($publicId) {
$task = Task::scope($publicId)->firstOrFail();
} else {
$task = Task::createNew();
}
if (isset($data['client']) && $data['client']) {
$task->client_id = Client::getPrivateId($data['client']);
}
if (isset($data['description'])) {
$task->description = trim($data['description']);
}
//$timeLog = $task->time_log ? json_decode($task->time_log, true) : [];
$timeLog = isset($data['time_log']) ? json_decode($data['time_log']) : [];
if ($data['action'] == 'start') {
$task->is_running = true;
$timeLog[] = [strtotime('now'), false];
} else {
if ($data['action'] == 'resume') {
$task->is_running = true;
$timeLog[] = [strtotime('now'), false];
} else {
if ($data['action'] == 'stop' && $task->is_running) {
$timeLog[count($timeLog) - 1][1] = time();
$task->is_running = false;
}
}
}
$task->time_log = json_encode($timeLog);
$task->save();
return $task;
}
示例5: getData
private function getData($request)
{
$account = Auth::user()->account;
$data = ['account' => $account, 'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()), 'multiUser' => $account->users->count() > 1];
if ($request->input(ENTITY_CLIENT)) {
$data['clients'] = Client::scope()->with('user', 'contacts', 'country')->withArchived()->get();
$data['contacts'] = Contact::scope()->with('user', 'client.contacts')->withTrashed()->get();
$data['credits'] = Credit::scope()->with('user', 'client.contacts')->get();
}
if ($request->input(ENTITY_TASK)) {
$data['tasks'] = Task::scope()->with('user', 'client.contacts')->withArchived()->get();
}
if ($request->input(ENTITY_INVOICE)) {
$data['invoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_quote', '=', false)->where('is_recurring', '=', false)->get();
$data['quotes'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_quote', '=', true)->where('is_recurring', '=', false)->get();
$data['recurringInvoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status', 'frequency')->withArchived()->where('is_quote', '=', false)->where('is_recurring', '=', true)->get();
}
if ($request->input(ENTITY_PAYMENT)) {
$data['payments'] = Payment::scope()->withArchived()->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')->get();
}
if ($request->input(ENTITY_VENDOR)) {
$data['clients'] = Vendor::scope()->with('user', 'vendorcontacts', 'country')->withArchived()->get();
$data['vendor_contacts'] = VendorContact::scope()->with('user', 'vendor.contacts')->withTrashed()->get();
/*
$data['expenses'] = Credit::scope()
->with('user', 'client.contacts')
->get();
*/
}
return $data;
}
示例6: save
public function save($publicId = null, $input)
{
if ($publicId) {
$payment = Payment::scope($publicId)->firstOrFail();
} else {
$payment = Payment::createNew();
}
$paymentTypeId = $input['payment_type_id'] ? $input['payment_type_id'] : null;
$payment->payment_type_id = $paymentTypeId;
$payment->payment_date = Utils::toSqlDate($input['payment_date']);
$payment->transaction_reference = trim($input['transaction_reference']);
if (!$publicId) {
$clientId = Client::getPrivateId($input['client']);
$amount = Utils::parseFloat($input['amount']);
if ($paymentTypeId == PAYMENT_TYPE_CREDIT) {
$credits = Credit::scope()->where('client_id', '=', $clientId)->where('balance', '>', 0)->orderBy('created_at')->get();
$applied = 0;
foreach ($credits as $credit) {
$applied += $credit->apply($amount);
if ($applied >= $amount) {
break;
}
}
}
$payment->client_id = $clientId;
$payment->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null;
$payment->amount = $amount;
}
$payment->save();
return $payment;
}
示例7: edit
public function edit($publicId)
{
$payment = Payment::scope($publicId)->firstOrFail();
$payment->payment_date = Utils::fromSqlDate($payment->payment_date);
$data = array('client' => null, 'invoice' => null, 'invoices' => Invoice::scope()->where('is_recurring', '=', false)->where('is_quote', '=', false)->with('client', 'invoice_status')->orderBy('invoice_number')->get(), 'payment' => $payment, 'method' => 'PUT', 'url' => 'payments/' . $publicId, 'title' => trans('texts.edit_payment'), 'paymentTypes' => Cache::get('paymentTypes'), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
return View::make('payments.edit', $data);
}
示例8: getDetail
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function getDetail($id)
{
$client = Client::find($id);
$data_clients = DataClient::with("client")->where("client_id", "=", $id)->get();
return view("clients.detail")->with(array('client' => $client, 'data_client' => $data_clients));
return redirect()->back();
}
示例9: save
public function save($data)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
if (!$publicId || $publicId == '-1') {
$client = Client::createNew();
} else {
$client = Client::scope($publicId)->with('contacts')->firstOrFail();
}
$client->fill($data);
$client->save();
/*
if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
return $client;
}
*/
$first = true;
$contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
$contactIds = [];
foreach ($contacts as $contact) {
$contact = $client->addContact($contact, $first);
$contactIds[] = $contact->public_id;
$first = false;
}
foreach ($client->contacts as $contact) {
if (!in_array($contact->public_id, $contactIds)) {
$contact->delete();
}
}
return $client;
}
示例10: edit
public function edit($publicId)
{
$credit = Credit::scope($publicId)->firstOrFail();
$credit->credit_date = Utils::fromSqlDate($credit->credit_date);
$data = array('client' => null, 'credit' => $credit, 'method' => 'PUT', 'url' => 'credits/' . $publicId, 'title' => 'Edit Credit', 'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
return View::make('credit.edit', $data);
}
示例11: __construct
public function __construct(Request $request)
{
/* This checks the client list for the CID. If a matching CID is found, all caching will be ignored
for this request */
if (Cache::has('clients')) {
$clients = Cache::get('clients');
} else {
$clients = Client::all();
Cache::put('clients', $clients, 1);
}
if (Cache::has('keys')) {
$keys = Cache::get('keys');
} else {
$keys = Key::all();
Cache::put('keys', $keys, 1);
}
$input_cid = $request->input('cid');
if (!empty($input_cid)) {
foreach ($clients as $client) {
if ($client->uuid == $input_cid) {
$this->client = $client;
}
}
}
$input_key = $request->input('k');
if (!empty($input_key)) {
foreach ($keys as $key) {
if ($key->api_key == $input_key) {
$this->key = $key;
}
}
}
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call(UserTableSeeder::class);
\App\Models\Client::truncate();
factory(\App\Models\Client::class, 10)->create();
Model::reguard();
}
示例13: index
public function index()
{
$clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get();
$clients = Utils::remapPublicIds($clients->toArray());
$response = json_encode($clients, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(count($clients));
return Response::make($response, 200, $headers);
}
示例14: getPedidos
public function getPedidos($id)
{
$client = Client::find($id);
$pedido = Pedido::with('client')->where('client_id', '=', $id)->get();
//dd($pedido->toArray());
return view("data_clients.pedidos")->with(array('client' => $client, 'pedido' => $pedido));
return redirect()->back();
}
示例15: handle
/**
* Handle the command.
*
* @param CreateClientCommand $command
* @return void
*/
public function handle(CreateClientCommand $command)
{
$client = Client::create(['name' => $command->name, 'pay' => $command->pay, 'due' => $command->due]);
if (!empty($client)) {
return $client;
}
return false;
}