小编use*_*472的帖子

如何在离子3中添加谷歌地图信息卡的滑块

我对离子框架很新.我想在滑块表单中添加多个标记以及信息卡,就像附加的图像一样.我能够在地图中添加多个标记,但不知道如何添加将激活标记的信息滑块.对应于滑块.可以请任何关于如何使用它的提示.

我的eventmap.ts文件显示多个标记

export class EventMapPage {
    public userToken:any;
    public userPostData = {"api_token":""};
    public responseData:any;
    public dataSet:any;



    @ViewChild('map') mapRef:ElementRef;

  constructor(...) {
      this.getEvents().then(result=> {
          this.responseData = result;
          this.DisplayMap(this.responseData);
      });

  }

     //Get all the available events
    getEvents(){
        const data = localStorage.getItem('userToken');
        this.userPostData.api_token= data;
        return this.authService.postData(this.userPostData,'events');
    }

    //Initializing the map


  DisplayMap(data) {
this.geolocation.getCurrentPosition().then((resp) => {
   const location = new google.maps.LatLng(resp.coords.latitude,
     resp.coords.longitude);
   const options = {
     center:location,
     zoom:10,
     mapTypeControl: false,
     streetViewControl:false,
   };
     const map = new google.maps.Map(this.mapRef.nativeElement,options);
     //Loop the markers
       if(data != null){
         for(var i=0; …
Run Code Online (Sandbox Code Playgroud)

google-maps ionic-framework ionic2

7
推荐指数
1
解决办法
1356
查看次数

Laravel redirect()->intended() 在自定义登录控制器中不起作用

我有一个自定义登录控制器及其 using return redirect()->intended(route('home')),根据文档,这应该将用户重定向到他们尝试访问的 URL,然后再被身份验证中间件拦截。

但是对于我的情况,每次重定向到home route.我确信我做得对,或者至少我认为我做得对。谁能告诉我我在哪里做错了??

我的logincontroller是这样的:

public function __construct()
    {
        $this->middleware('guest');
    }

 public function login(Request $request)
    {
        $validatedData = $request->validate([
            'email' => 'required|email|max:255',
            'password' => 'required|max:255',
        ]);
        try {
            $response = HelperFunctions::fetchData('post', 'login/login', [
                'loginId' => $request->get('email'),
                'password' => md5($request->get('password'))
            ]);
            if ($response['code'] == 200 && $response['success']) {
                session([
                    'api_token' => $response['sessionId'],
                    'user_data' => $response['data']['profile']
                ]);

                return redirect()->intended(route('home'));
            } else {
                return redirect()->back()->with('error', 'Please provide valid credentials');
            }
        } catch (\Exception $e) { …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-4 laravel-5

5
推荐指数
1
解决办法
5654
查看次数

我如何从 React Native 中的辅助函数中调度一个动作

我有一个helper.js文件,其中包含所有辅助函数,包括带有 axios 的 HTTP 请求处理程序。这是我的helper.js文件代码:

const HTTPRequest = (path, body, method = 'POST', authorizedToken = null) => {
    return new Promise((resolve, reject) => {
        let headers = {
            'Content-type': 'multipart/form-data',
        };

        // Set authorization token
        if (authorizedToken) {
            headers['Authorization'] = "JWT " + authorizedToken;  // Here i want to get user token from the redux store not though passing the token

        }

        const fulHeaderBody = {
            method,
            headers,
            timeout: 20,
            url: path
        };


axios(fulHeaderBody).then(response => { …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native redux react-redux

5
推荐指数
1
解决办法
5332
查看次数

如何将laravel迁移文件迁移到mongodb

我对 laravel 还很陌生,也是 monogo db 的初学者。我一直在尝试在我的 Laravel 项目中连接 mongodb 图集的 mongodb 集群。但是,当我尝试迁移 Laravel 迁移文件时,即使将默认连接更改为 mongodb,它也显示错误,指出 mysql 错误。谁能告诉我如何解决这个问题并将当前项目迁移到 mongodb?

PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead", "homestead", "secret", [])

  1   PDOException::("SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.
")
      C:\Users\admin\Desktop\test\test\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php : 68

      C:\Users\admin\Desktop\test\test\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php : 68
Run Code Online (Sandbox Code Playgroud)

由于 laravel 不允许开箱即用的 mongodb,所以我使用的是 mongodb 包https://github.com/jenssegers/laravel-mongodb 而且我还想提一下,我已经按照文档在我的 php 中安装了 monngodb。我可以在phpinfo()页面上看到mongodb的确认。我的设置如下:

我的 .env

        DB_CONNECTION="mongodb"
        DB_MONGO_PORT=27017
        DB_MONGO_DATABASE=test
        DB_MONGO_DSN="mongodb+srv://<USERNAME>:<PASSWORD>@cluster0-
***.mongodb.net/test"
Run Code Online (Sandbox Code Playgroud)

我的配置/database.php

 'default' => env('DB_CONNECTION', 'mongodb'),

'mongodb' => [
            'driver'   => 'mongodb',
            'dsn' => env('DB_MONGO_DSN'),
            'database' => …
Run Code Online (Sandbox Code Playgroud)

php mongodb laravel laravel-5

4
推荐指数
1
解决办法
8419
查看次数

调用 float LARAVEL 上的成员函数 addEagerConstraints()

我的目标是获得对可用课程的平均评价。但是当我试图获得课程的平均评价时,它给了我一个错误:"message": "Call to a member function addEagerConstraints() on float"

我的课程模型

 public function rating(){
    return $this->hasMany(Rating::class);
}
public function averageRating(){
    return round($this->rating()->avg('ratings'),1);
}
Run Code Online (Sandbox Code Playgroud)

评级模型

 public function user(){
        return $this->belongsTo(User::class);
    }
    public function course(){
        return $this->belongsTo(Course::class);
    }
Run Code Online (Sandbox Code Playgroud)

我的控制器

$result = Course::with('averageRating')->get();
Run Code Online (Sandbox Code Playgroud)

我希望它能提供课程详细信息以及每门课程的平均评分,但它抛出了错误。谁能帮帮我吗??谢谢

php mysql laravel eloquent laravel-5

2
推荐指数
1
解决办法
5651
查看次数

Laravel 附加属性不起作用

我的目标是附加每个产品的平均评分,以便我可以在前端显示

我有两张桌子,一张是products,另一张是reviews

我的review model

class Review extends Model 
{

    protected $table = 'reviews';
    public $timestamps = true;

    use SoftDeletes;

    protected $dates = ['deleted_at'];
    protected $fillable = array('user_id', 'product_id', 'rating', 'feedback');

    public function user()
    {
        return $this->belongsTo('App\Models\User');
    }

    public function product()
    {
        return $this->belongsTo('App\Models\Product');
    }

}
Run Code Online (Sandbox Code Playgroud)

我的product model

protected $appends = ['average_rating','my_rating'];


   // i added these accoceries inside class as per the laravel documentation
 public function reviews()
    {
        return $this->hasMany(Review::class);
    }


    public function getAverageRatingAttribute(){
        return round($this->reviews()->avg('rating'),1); …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent laravel-4 laravel-5

2
推荐指数
1
解决办法
7044
查看次数

可能未处理的承诺拒绝(id:0)反应原生的警告

我试图在反应原生的AsyncStorage中存储数据时收到此错误,并且数据也没有添加到存储

可能的未处理的Promise拒绝(id:0):错误:com.facebook.react.bridge.ReadableNativeMap无法强制转换为java.lang.String错误:com.facebook.react.bridge.ReadableNativeMap无法强制转换为java.lang.String*

我的代码是这样的

  //Public methods
  static addProduct(id,name,qnty){

    let   product={
        id:id,
        name:name,
        qty:qnty,

      };
      let cartResponse={};
      product.rowId = this.generateHash(hashItem);
        AsyncStorage.getItem('CART').then((data) => {
          //Check if the product already in the cartTotalItem
          if (data !== null && data.length>0) {
              if (this.checkIfExist(product.rowId)) {
                //Update product quantity
                data[product.rowId]['qty'] += product.qty;
              }else{
                //Add add product to the storage
                data[product.rowId] = product;
              }
              //Update storage with new data
              AsyncStorage.setItem("CART", data);
              cartResponse = data;
          }else{
            let cartItem ={};
            cartItem[product.rowId] =product;
              AsyncStorage.setItem("CART", cartItem);
              cartResponse =cartItem;
          }
            return true; …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native

2
推荐指数
1
解决办法
6166
查看次数

Angular 7:如何获取当前页面的完整URL

如何在不使用angular 7的情况下获取完整的当前URL window.location.href

例如,假设我当前的网址是 http://localhost:8080/p/drinks?q=cold&price=200

如何获得完整的URL而不仅仅是完整的URL /p/drinks?q=cold&price=200

我已经尝试过使用this.router.url此命令,但/p/drinks?q=cold&price=200不能提供完整的主机名。

我不想使用的window.location.href原因是它导致ng-toolkit / universal中的渲染出现问题

我尝试遵循此解决方案,这似乎与我存在相同的问题,并且也进行了更新

如何在Angular2中获取服务域名

这是我的代码

windowProvider.js

import { InjectionToken, FactoryProvider } from '@angular/core';

export const WINDOW = new InjectionToken<Window>('window');

const windowProvider: FactoryProvider = {
  provide: WINDOW,
  useFactory: () => window
};

export const WINDOW_PROVIDERS = [
  windowProvider
];
Run Code Online (Sandbox Code Playgroud)

app.module.ts中

@NgModule({
    .......
    providers:[
    .......
    windowProvider
   ]
})
Run Code Online (Sandbox Code Playgroud)

在我的必填页面中:

import {WINDOW as WindowFactory} from '../../factory/windowProvider';
......
 constructor(private router: Router, private helper: Helpers, …
Run Code Online (Sandbox Code Playgroud)

javascript angular-universal angular angular7

2
推荐指数
1
解决办法
2205
查看次数

FBSDKCoreKit/FBSDKCoreKit.modulemap' 尝试在 XCODE 上存档本机项目时未找到

当我在 IOS 模拟器上尝试 React Native 项目时,它工作正常。但是当尝试将项目存档以上传到 App Store 时,Xcode 会抛出一个错误说

fatal error: module map file '/Users/MyMac/Library/Developer/Xcode/DerivedData/<coolapp>-gsdebkxdyslzmjaypmxjdztvchbl/Build/Intermediates.noindex/ArchiveIntermediates/coolapp/BuildProductsPath/Release-iphoneos/FBSDKCoreKit/FBSDKCoreKit.modulemap' not found
Run Code Online (Sandbox Code Playgroud)

当它在项目中明确存在时。我已经尝试了此 GitHub 线程上发布的所有解决方案,但没有一个奏效。 https://github.com/facebook/react-native-fbsdk/issues/780

我的环境

  • react-native: 0.63.2
  • react-native-fbsdk: ^3.0.0
  • Xcode 12.4 (12D4e)

也试过fbsdk 2.0.0和代码 11.0+ 仍然是同样的问题。

谁能帮帮我吗。

xcode ios react-native

2
推荐指数
1
解决办法
1870
查看次数

Laravel API TOKEN 身份验证不起作用

我正在尝试使用api authentication token. 但即使在使用正确的令牌后,它的说法未经授权。

我使用 laravel auth 和 socialite 进行社交认证,所以我的api.php路线是这样的

Route::group(['middleware'=>'auth:api'], function(){
  Route::get('hello','ApiTestControler@index');
});
Run Code Online (Sandbox Code Playgroud)

我试图用这个网址访问这个

http://localhost:8000/api/hello 并在标题中

token: TOKEN HERE 
Content-Type: application/json 
Accept: application/json
Run Code Online (Sandbox Code Playgroud)

我期待它让我登录并显示 ApiTestController index methord

但它抛出一个错误401 unauthorized 我如何解决这个问题并使用 API 令牌获取用户身份验证?

我的控制器

 class ApiTestController extends Controller
{
  public function index(){
    return json_encode ("Welcome REST API");
  }
}
Run Code Online (Sandbox Code Playgroud)

用户迁移表

        $table->increments('id');
        $table->string('name')->unique();
        $table->string('first_name')->nullable();
        $table->string('last_name')->nullable();
        $table->string('email')->unique()->nullable();
        $table->string('password');
        $table->rememberToken();
        $table->boolean('activated')->default(false);
        $table->string('token');
        $table->ipAddress('signup_ip_address')->nullable();
        $table->ipAddress('signup_confirmation_ip_address')->nullable();
        $table->ipAddress('signup_sm_ip_address')->nullable();
        $table->ipAddress('admin_ip_address')->nullable();
        $table->ipAddress('updated_ip_address')->nullable();
        $table->ipAddress('deleted_ip_address')->nullable();
        $table->timestamps();
        $table->softDeletes();
Run Code Online (Sandbox Code Playgroud)

和身份验证配置 config\auth.php

'guards' => [
        'web' => [ …
Run Code Online (Sandbox Code Playgroud)

authentication oauth-2.0 laravel-5 laravel-socialite laravel-passport

1
推荐指数
1
解决办法
9323
查看次数

如何使用社交网络谷歌驱动程序从谷歌获取用户数据

我正在尝试使用 laravel google socialite 驱动程序,我需要使用从 api 调用中获取的访问令牌从 google 获取用户数据。但是当我认为我做的一切都正确时,它给出了一个错误说Call to protected method Laravel\\Socialite\\Two\\GoogleProvider::getUserByToken()

我知道它说我无法访问该方法,因为它受到保护。那么如何解决这个问题。

我的目标

我的目标是验证我从我的移动应用程序获取的社交访问(基本上是谷歌)令牌,并将该用户的该特定用户的数据存储到我从社交名流 My Route 中收到的数据库中 api.php

Route::post('login','api\unAuthApiCall@index');
Run Code Online (Sandbox Code Playgroud)

我的控制器

namespace App\Http\Controllers\api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Laravel\Socialite\Facades\Socialite;


class unAuthApiCall extends Controller
{
    //Get the authentication token
    public function index(Request $request){

        //get the auth token
        $authToken= Input::get('auth_token');

        //Validate authtoken with google and get user's data
        $driver = Socialite::driver('google');

        $socialUserObject= $driver->getUserByToken($authToken);

        return json_encode($socialUserObject);
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到的回应

{
    "message": "Call to protected method Laravel\\Socialite\\Two\\GoogleProvider::getUserByToken() from context 'App\\Http\\Controllers\\api\\unAuthApiCall'", …
Run Code Online (Sandbox Code Playgroud)

google-api oauth-2.0 laravel laravel-socialite laravel-5.5

0
推荐指数
1
解决办法
3767
查看次数