本文整理汇总了PHP中app\Client类的典型用法代码示例。如果您正苦于以下问题:PHP Client类的具体用法?PHP Client怎么用?PHP Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(Client $client, ClientRequest $request)
{
//Client $client refrences a Route Model Binding method found is RouteServiceProvider.php
$client->update($request->all());
\Session::flash('flash_message', 'Client ' . $client->first_name . ' ' . $client->last_name . ' was updated.');
return redirect('clients');
}
示例2: create
/**
* Handle creation of new bill.
*
* @param CreateBillRequest $request
* @return array
*/
public function create(CreateBillRequest $request)
{
// Save request data
$clientName = $request->get('client');
$useCurrentCampaign = $request->get('use_current_campaign');
$campaignYear = $request->get('campaign_year');
$campaignNumber = $request->get('campaign_number');
$client = DB::table('clients')->where('name', $clientName)->where('user_id', Auth::user()->id)->first();
// Create new client if not exists
if (!$client) {
$client = new Client();
$client->user_id = Auth::user()->id;
$client->name = $clientName;
$client->save();
}
// Create new bill
$bill = new Bill();
$bill->client_id = $client->id;
$bill->user_id = Auth::user()->id;
$campaign = Campaigns::current();
// Check if current campaign should be used
if (!$useCurrentCampaign) {
$campaign = Campaign::where('year', $campaignYear)->where('number', $campaignNumber)->first();
}
$bill->campaign_id = $campaign->id;
$bill->campaign_order = Campaigns::autoDetermineOrderNumber($campaign, $client->id);
$bill->save();
event(new UserCreatedNewBill(Auth::user()->id, $bill->id));
// Return response
$response = new AjaxResponse();
$response->setSuccessMessage(trans('bills.bill_created'));
return response($response->get());
}
示例3: submitOTP
public function submitOTP(Request $request)
{
//get mobile number from user input
$mobileNum = $request->input('mobile');
//get user type from user input
$userType = $request->input('userType');
//set user email
$userEmail = 'new_user@email.com';
//set country code
$countryCode = 61;
//initial authentication API
// $authy_api = new AuthyApi(config('services.authy.key'));
$authy_api = new AuthyApi(config('services.authy.key'), 'http://sandbox-api.authy.com');
//sandbox
//register a user through email, cellphone, country_code
$user = $authy_api->registerUser($userEmail, $mobileNum, $countryCode);
//generate authentication token and send it to usser
$sms = $authy_api->requestSms($user->id(), array("force" => "true"));
if ($sms->ok()) {
//check user exist or not
$results = Client::where('mobile', $mobileNum)->first();
//if user does not exist, register of him
if (empty($results)) {
$newUser = new Client();
$newUser->mobile = $mobileNum;
$newUser->save();
}
return view('auth.otp')->with('userid', $user->id())->with('mobileNum', $mobileNum)->with('userType', $userType);
} else {
//session()->put('message','incorrect mobile number');
return redirect('login')->with('message', 'Please input correct mobile number');
}
}
示例4: testClientSave
public function testClientSave()
{
$client = new Client();
$client->name = 'Idea7';
$client->country = 'IN';
$client->status = 'active';
if (!$client->save()) {
$errors = $client->getErrors()->all();
echo 'Client Insert failed' . print_r($errors);
$this->assertTrue(false);
} else {
$this->assertTrue(true);
}
}
示例5: destroy
public function destroy($id)
{
$client = Client::find($id);
$client->delete();
$clients = Client::all();
return view('client.list')->with(['success' => 'Cliente excluído com sucesso!', 'clients' => $clients]);
}
示例6: edit
public function edit($id)
{
$access = Access::findOrFail($id);
$client = Client::all()->lists('name', 'id');
$selected = array();
return view('access.edit', compact('access', 'client', 'selected'));
}
示例7: handleAction
public function handleAction(Request $request)
{
$action = $request->input('_action');
if ($action == 'createClient') {
//Creation :
Client::create($request->all());
// FLash messaging :
flash()->success('Opération réussie!', 'Client créé avec succès.');
} else {
if ($_POST['_action'] == 'getClientByID') {
$id = $_POST['_uid'];
$client = Client::where('id', $id)->with('files')->first();
return response(['status' => 'success', 'client' => $client], 200);
} else {
if ($_POST['_action'] == 'editClient') {
$id = $_POST['id'];
$client = Client::find($id);
$client->lastname = $_POST['lastname'];
$client->firstname = $_POST['firstname'];
$client->email = $_POST['email'];
$client->street = $_POST['street'];
$client->postal_code = $_POST['postal_code'];
$client->city = $_POST['city'];
$client->vat = $_POST['tva'];
$client->mobile = $_POST['mobile'];
$client->office = $_POST['office'];
$client->fax = $_POST['fax'];
$client->save();
flash()->success('Opération réussie!', 'Client modifé avec succès.');
} else {
}
}
}
return redirect('/clients');
}
示例8: name
/**
* Get the name of the user
*/
public function name()
{
if ($this->Type == 1) {
return Worker::find($this->TypeId)->Name;
}
return Client::find($this->TypeId)->Name;
}
示例9: show
/**
* Display the specified resource.
*
* @param RentalAgreement $agreement
* @return Response
* @internal param int $id
*/
public function show(RentalAgreement $agreement)
{
$address = Address::find($agreement->property_id);
$client = Client::find($agreement->client_id);
$owner = Client::find($agreement->owner_id);
return view('agreement.showAgreement', compact('agreement', 'address', 'client', 'owner'));
}
示例10: clientsByName
static function clientsByName()
{
$clients = Client::orderBy('name')->get(['id', 'name'])->getDictionary();
return array_map(function ($client) {
return $client->name;
}, $clients);
}
示例11: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$client = false;
if ($this->method() == 'PATCH') {
$routeAction = $this->route()->getAction();
$routeParameters = $this->route()->parameters();
$cid = false;
if (isset($routeParameters['clientId'])) {
$cid = $routeParameters['clientId'];
} else {
if (isset($routeParameters['one'])) {
$cid = $routeParameters['one'];
}
}
$client = \App\Client::find($cid);
if (!$client) {
dd('error');
}
}
switch ($this->method()) {
case 'GET':
case 'DELETE':
return [];
case 'PUT':
return ['name' => 'required|unique:clients,name'];
case 'PATCH':
return ['name' => 'required|unique:clients,name,' . $client->id];
default:
return [];
break;
}
}
示例12: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$client = Client::findOrFail($id);
$addressId = $client->addresses()->first()->id;
$address = Address::findOrFail($addressId);
return view('editAddress', compact('address', 'client'));
}
示例13: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
$router->bind('client', function ($value, $route) {
$hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
$id = $hashids->decode($value)[0];
return Client::findOrFail($id);
});
$router->bind('bank', function ($value, $route) {
$hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
$id = $hashids->decode($value)[0];
return BankDetail::findOrFail($id);
});
$router->bind('address', function ($value, $route) {
$hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
$id = $hashids->decode($value)[0];
return Address::findOrFail($id);
});
$router->bind('property', function ($value, $route) {
$hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
$id = $hashids->decode($value)[0];
return Property::findOrFail($id);
});
$router->bind('agreement', function ($value, $route) {
$hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
$id = $hashids->decode($value)[0];
return RentalAgreement::findOrFail($id);
});
//
}
示例14: destroy
/**
* Remove the specified resource from storage.
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$client = Client::findOrFail($id);
$name = $client->name . " " . $client->lastname;
Client::destroy($id);
return redirect(route('clients.index'))->with('message', 'Cliente ' . $name . ' eliminado corectamente');
}
示例15: clientsForUser
public function clientsForUser($user = null)
{
if ($user != null) {
return \App\Client::where('user_id', $user->id)->get();
}
return \App\Client::where('user_id', $this->user()->id)->get();
}