本文整理汇总了PHP中Admin::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::first方法的具体用法?PHP Admin::first怎么用?PHP Admin::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::first方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
Route::get('/', function () {
return View::make("base")->with("currentMenu", "main")->nest("conetent", "intro.index", []);
});
Route::get("/main", function () {
return View::make("base")->with("currentMenu", "main")->nest("conetent", "intro.main", []);
});
Route::get("/admin", function () {
$admin = Admin::first();
$admin_users = AdminUser::all();
$admin_access_subnet = AdminAccessSubnet::all();
$admin_ntp_servers = AdminNtpServer::all();
// dd($admin);
return View::make("base")->with("currentMenu", "admin")->nest("conetent", "intro.admin", ["admin" => $admin, "admin_users" => $admin_users, "admin_access_subnet" => $admin_access_subnet, "admin_ntp_servers" => $admin_ntp_servers]);
});
Route::post("/admin/save", function () {
$admin = Admin::first();
// dd(Input::get("datetime_offset"),$admin);
$admin->hostname = Input::get("hostname");
$admin->location = Input::get("location");
$admin->contacts = Input::get("contacts");
$admin->access_read = Input::get("access_read");
$admin->access_write = Input::get("access_write");
$admin->access_filter = Input::get("access_filter");
$admin->timezone = Input::get("timezone");
$admin->datetime_offset = Input::get("datetime_offset");
// $admin->time = Input::get("time");
$admin->save();
return "ok";
});
Route::post("/admin/save/users", function () {
DB::table('admin_users')->truncate();
示例2: get_completed_requests
public function get_completed_requests()
{
$walker_id = Input::get('id');
$token = Input::get('token');
$from = Input::get('from_date');
// 2015-03-11 07:45:01
$to_date = Input::get('to_date');
//2015-03-11 07:45:01
$validator = Validator::make(array('walker_id' => $walker_id, 'token' => $token), array('walker_id' => 'required|integer', 'token' => 'required'));
if ($validator->fails()) {
$error_messages = $validator->messages()->all();
$response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
$response_code = 200;
} else {
$is_admin = $this->isAdmin($token);
if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) {
// check for token validity
if (is_token_active($walker_data->token_expiry) || $is_admin) {
if ($from != "" && $to_date != "") {
$request_data = DB::table('request')->where('request.confirmed_walker', $walker_id)->where('request.is_completed', 1)->where('request_start_time', '>', $from)->where('request_start_time', '<', $to_date)->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('request_services', 'request_services.request_id', '=', 'request.id')->select('request.*', 'request.request_start_time', 'request.transfer_amount', 'owner.first_name', 'owner.last_name', 'owner.phone', 'owner.email', 'owner.picture', 'owner.bio', 'request.distance', 'request.time', 'request.promo_code', 'request_services.base_price', 'request_services.distance_cost', 'request_services.time_cost', 'request.total')->get();
} else {
$request_data = DB::table('request')->where('request.confirmed_walker', $walker_id)->where('request.is_completed', 1)->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('request_services', 'request_services.request_id', '=', 'request.id')->select('request.*', 'request.request_start_time', 'request.transfer_amount', 'owner.first_name', 'owner.last_name', 'owner.phone', 'owner.email', 'owner.picture', 'owner.bio', 'request.distance', 'request.time', 'request.promo_code', 'request_services.base_price', 'request_services.distance_cost', 'request_services.time_cost', 'request.total')->get();
}
$requests = array();
$settings = Settings::where('key', 'default_distance_unit')->first();
/* $setbase_price = Settings::where('key', 'base_price')->first();
$setdistance_price = Settings::where('key', 'price_per_unit_distance')->first();
$settime_price = Settings::where('key', 'price_per_unit_time')->first(); */
$unit = $settings->value;
if ($unit == 0) {
$unit_set = 'kms';
} elseif ($unit == 1) {
$unit_set = 'miles';
}
$walker = Walker::where('id', $walker_id)->first();
foreach ($request_data as $data) {
$discount = 0;
if ($data->promo_id != "") {
$promo_code = PromoCodes::where('id', $data->promo_id)->first();
if (isset($promo_code->id)) {
$promo_value = $promo_code->value;
$promo_type = $promo_code->type;
if ($promo_type == 1) {
// Percent Discount
$discount = $data->total * $promo_value / 100;
} elseif ($promo_type == 2) {
// Absolute Discount
$discount = $promo_value;
}
}
}
$is_multiple_service = Settings::where('key', 'allow_multiple_service')->first();
if ($is_multiple_service->value == 0) {
$requestserv = RequestServices::where('request_id', $data->id)->first();
$request_typ = ProviderType::where('id', '=', $requestserv->type)->first();
$request['id'] = $data->id;
$request['date'] = $data->request_start_time;
$request['distance'] = (string) $data->distance;
$request['unit'] = $unit_set;
$request['time'] = $data->time;
$request['base_distance'] = $request_typ->base_distance;
/* $currency = Keywords::where('alias', 'Currency')->first();
$request['currency'] = $currency->keyword; */
$request['currency'] = Config::get('app.generic_keywords.Currency');
if ($requestserv->base_price != 0) {
$request['base_price'] = currency_converted($requestserv->base_price);
$request['distance_cost'] = currency_converted($requestserv->distance_cost);
$request['time_cost'] = currency_converted($requestserv->time_cost);
} else {
/* $setbase_price = Settings::where('key', 'base_price')->first();
$request['base_price'] = currency_converted($setbase_price->value);
$setdistance_price = Settings::where('key', 'price_per_unit_distance')->first();
$request['distance_cost'] = currency_converted($setdistance_price->value);
$settime_price = Settings::where('key', 'price_per_unit_time')->first();
$request['time_cost'] = currency_converted($settime_price->value); */
$request['base_price'] = currency_converted($request_typ->base_price);
$request['distance_cost'] = currency_converted($request_typ->price_per_unit_distance);
$request['time_cost'] = currency_converted($request_typ->price_per_unit_time);
}
$admins = Admin::first();
$request['walker']['email'] = $walker->email;
$request['admin']['email'] = $admins->username;
if ($data->transfer_amount != 0) {
$request['walker']['amount'] = currency_converted($data->total - $data->transfer_amount);
$request['admin']['amount'] = currency_converted($data->transfer_amount);
} else {
$request['walker']['amount'] = currency_converted($data->transfer_amount);
$request['admin']['amount'] = currency_converted($data->total - $data->transfer_amount);
}
$request['total'] = currency_converted($data->total + $data->ledger_payment + $discount);
$rserv = RequestServices::where('request_id', $data->id)->get();
$typs = array();
$typi = array();
$typp = array();
$total_price = 0;
foreach ($rserv as $typ) {
$typ1 = ProviderType::where('id', $typ->type)->first();
$typ_price = ProviderServices::where('provider_id', $data->confirmed_walker)->where('type', $typ->type)->first();
if ($typ_price->base_price > 0) {
$typp1 = 0.0;
//.........这里部分代码省略.........
示例3: paybypalwebSubmit
public function paybypalwebSubmit()
{
// Normal Payment
$request_id = Request::segment(3);
$request = Requests::where('id', $request_id)->first();
$reqserv = RequestServices::where('request_id', $request_id)->first();
$typess = ProviderType::where('id', $reqserv->type)->first();
$total_amount = $request->total;
$service_name = $typess->name;
$owner = Owner::where('id', $request->owner_id)->first();
$walker = Walker::where('id', $request->confirmed_walker)->first();
$admins = Admin::first();
// Adaptive payments
// check if transfer is allowed
$transfersett = Settings::where('key', 'transfer')->first();
$payRequest = new PayRequest();
if ($transfersett->value == 1) {
$receiver = array();
$receiver[0] = new Receiver();
$receiver[0]->amount = $request->total - $request->transfer_amount;
// $receiver[0]->email = "testpaypal34@gmail.com";
$receiver[0]->email = $admins->username;
$receiver[0]->primary = "true";
$receiver[1] = new Receiver();
$receiver[1]->amount = $request->transfer_amount;
// $receiver[1]->email = "joydhanbad@gmail.com";
$receiver[1]->email = $walker->email;
} else {
$receiver = array();
$receiver[0] = new Receiver();
$receiver[0]->amount = $request->total;
// $receiver[0]->email = "testpaypal34@gmail.com";
$receiver[0]->email = $admins->username;
$receiver[0]->primary = "true";
}
$receiverList = new ReceiverList($receiver);
$payRequest->receiverList = $receiverList;
$requestEnvelope = new RequestEnvelope("en_US");
$payRequest->requestEnvelope = $requestEnvelope;
$payRequest->actionType = "PAY";
$payRequest->cancelUrl = URL::route('userpaypalstatus');
$payRequest->returnUrl = URL::route('userpaypalstatus');
$payRequest->currencyCode = "USD";
$payRequest->ipnNotificationUrl = URL::route('userpaypalipn');
$sdkConfig = array("mode" => Config::get('app.paypal_sdk_mode'), "acct1.UserName" => Config::get('app.paypal_sdk_UserName'), "acct1.Password" => Config::get('app.paypal_sdk_Password'), "acct1.Signature" => Config::get('app.paypal_sdk_Signature'), "acct1.AppId" => Config::get('app.paypal_sdk_AppId'));
$adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
$payResponse = $adaptivePaymentsService->Pay($payRequest);
Log::info('payResponse = ' . print_r($payResponse, true));
return Redirect::to('userpaypalstatus');
}
示例4: get_request
public function get_request()
{
$request_id = Input::get('request_id');
$token = Input::get('token');
$owner_id = Input::get('id');
$validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'owner_id' => $owner_id), array('request_id' => 'required|integer', 'token' => 'required', 'owner_id' => 'required|integer'));
/* $var = Keywords::where('id', 2)->first(); */
if ($validator->fails()) {
$error_messages = $validator->messages()->all();
$response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
$response_code = 200;
} else {
$is_admin = $this->isAdmin($token);
if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
// check for token validity
if (is_token_active($owner_data->token_expiry) || $is_admin) {
/* SEND REFERRAL & PROMO INFO */
$settings = Settings::where('key', 'referral_code_activation')->first();
$referral_code_activation = $settings->value;
if ($referral_code_activation) {
$referral_code_activation_txt = "referral on";
} else {
$referral_code_activation_txt = "referral off";
}
$settings = Settings::where('key', 'promotional_code_activation')->first();
$promotional_code_activation = $settings->value;
if ($promotional_code_activation) {
$promotional_code_activation_txt = "promo on";
} else {
$promotional_code_activation_txt = "promo off";
}
/* SEND REFERRAL & PROMO INFO */
// Do necessary operations
if ($request = Requests::find($request_id)) {
if ($request->owner_id == $owner_data->id) {
if ($request->current_walker != 0) {
if ($request->confirmed_walker != 0) {
$walker = Walker::where('id', $request->confirmed_walker)->first();
$walker_data = array();
$walker_data['unique_id'] = 1;
$walker_data['id'] = $walker->id;
$walker_data['first_name'] = $walker->first_name;
$walker_data['last_name'] = $walker->last_name;
$walker_data['phone'] = $walker->phone;
$walker_data['bio'] = $walker->bio;
$walker_data['picture'] = $walker->picture;
$walker_data['latitude'] = $walker->latitude;
$walker_data['longitude'] = $walker->longitude;
if ($request->D_latitude != NULL) {
$walker_data['d_latitude'] = $request->D_latitude;
$walker_data['d_longitude'] = $request->D_longitude;
}
$walker_data['type'] = $walker->type;
$walker_data['rating'] = $walker->rate;
$walker_data['num_rating'] = $walker->rate_count;
$walker_data['car_model'] = $walker->car_model;
$walker_data['car_number'] = $walker->car_number;
$walker_data['bearing'] = $walker->bearing;
/* $walker_data['rating'] = DB::table('review_walker')->where('walker_id', '=', $walker->id)->avg('rating') ? : 0;
$walker_data['num_rating'] = DB::table('review_walker')->where('walker_id', '=', $walker->id)->count(); */
$settings = Settings::where('key', 'default_distance_unit')->first();
$unit = $settings->value;
if ($unit == 0) {
$unit_set = 'kms';
} elseif ($unit == 1) {
$unit_set = 'miles';
}
$requestserv = RequestServices::where('request_id', $request->id)->first();
$bill = array();
$request_typ = ProviderType::where('id', '=', $requestserv->type)->first();
/* $currency_selected = Keywords::find(5);
$cur_symb = $currency_selected->keyword; */
$cur_symb = Config::get('app.generic_keywords.Currency');
if ($request->is_completed == 1) {
$bill['unit'] = $unit_set;
$bill['payment_mode'] = $request->payment_mode;
$bill['distance'] = (string) $request->distance;
$bill['time'] = $request->time;
if ($requestserv->base_price != 0) {
$bill['base_distance'] = $request_typ->base_distance;
$bill['base_price'] = currency_converted($requestserv->base_price);
$bill['distance_cost'] = currency_converted($requestserv->distance_cost);
$bill['time_cost'] = currency_converted($requestserv->time_cost);
} else {
/* $setbase_price = Settings::where('key', 'base_price')->first();
$bill['base_price'] = currency_converted($setbase_price->value);
$setdistance_price = Settings::where('key', 'price_per_unit_distance')->first();
$bill['distance_cost'] = currency_converted($setdistance_price->value);
$settime_price = Settings::where('key', 'price_per_unit_time')->first();
$bill['time_cost'] = currency_converted($settime_price->value); */
$bill['base_distance'] = $request_typ->base_distance;
$bill['base_price'] = currency_converted($request_typ->base_price);
$bill['distance_cost'] = currency_converted($request_typ->price_per_unit_distance);
$bill['time_cost'] = currency_converted($request_typ->price_per_unit_time);
}
if ($request->payment_mode == 2) {
$bill['walker']['email'] = $walker->email;
$bill['walker']['amount'] = currency_converted($request->transfer_amount);
$admins = Admin::first();
$bill['admin']['email'] = $admins->username;
//.........这里部分代码省略.........
示例5: function
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function () {
if (Auth::check()) {
return Redirect::to('/');
}
});
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('new_installation', function () {
if (Config::get("database.connections.mysql.database") != "") {
if (Admin::first()) {
return Redirect::route('admin');
}
}
});
Route::filter('csrf', function () {
if (Session::token() != Input::get('_token')) {
throw new Illuminate\Session\TokenMismatchException();
}
});