如何从$ user中检索状态值?

时间:2017-07-26 10:56:37

标签: php laravel status

protected function authenticated(Request $request, $user)
    {
        //
        $user = User::findOrFail($user);
        return $user;
        //$arruser = $user->toArray();
      /*  if($user->status==0){
          Auth::logout();
          return redirect('login')->with('verify_info','Verify First');
        }*/
    }

$ user returns --->

id 54
name "Rasul"
email "golam.rasul@gmail.com"
verify_token "BiOF8L8DJb"
status 0
created_at "2017-07-26 09:39:46"
updated_at "2017-07-26 09:39:46"
Problem is when i m trying to get value of status using 

$用户>状态  它表示此集合实例上不存在Property [status]。

1 个答案:

答案 0 :(得分:0)

当你first()时,你会得到一个集合 如何通过 $user = User::findOrFail($user)->first(); return $user; 获取对象,然后获取属性状态。

这样的事情:

extension UIImage {

    func fixImageOrientation() -> UIImage? {


        if (self.imageOrientation == .up) {
            return self
        }

        var transform: CGAffineTransform = CGAffineTransform.identity


        if ( self.imageOrientation == .left || self.imageOrientation == .leftMirrored ) {
            transform = transform.translatedBy(x: self.size.width, y: 0)
            transform = transform.rotated(by: CGFloat(Double.pi / 2.0))
        } else if ( self.imageOrientation == .right || self.imageOrientation == .rightMirrored ) {
            transform = transform.translatedBy(x: 0, y: self.size.height);
            transform = transform.rotated(by: CGFloat(-Double.pi / 2.0));
        } else if ( self.imageOrientation == .down || self.imageOrientation == .downMirrored ) {
            transform = transform.translatedBy(x: self.size.width, y: self.size.height)
            transform = transform.rotated(by: CGFloat(Double.pi))
        } else if ( self.imageOrientation == .upMirrored || self.imageOrientation == .downMirrored ) {
            transform = transform.translatedBy(x: self.size.width, y: 0)
            transform = transform.scaledBy(x: -1, y: 1)
        } else if ( self.imageOrientation == .leftMirrored || self.imageOrientation == .rightMirrored ) {
            transform = transform.translatedBy(x: self.size.height, y: 0);
            transform = transform.scaledBy(x: -1, y: 1);
        }


        if let context: CGContext = CGContext(data: nil, width: Int(self.size.width), height: Int(self.size.height),
                                       bitsPerComponent: self.cgImage!.bitsPerComponent, bytesPerRow: 0,
                                       space: self.cgImage!.colorSpace!,
                                       bitmapInfo: self.cgImage!.bitmapInfo.rawValue) {

            context.concatenate(transform)

            if ( self.imageOrientation == UIImageOrientation.left ||
                self.imageOrientation == UIImageOrientation.leftMirrored ||
                self.imageOrientation == UIImageOrientation.right ||
                self.imageOrientation == UIImageOrientation.rightMirrored ) {
                context.draw(self.cgImage!, in: CGRect(x: 0,y: 0,width: self.size.height,height: self.size.width))
            } else {
                context.draw(self.cgImage!, in: CGRect(x: 0,y: 0,width: self.size.width,height: self.size.height))
            }

            if let contextImage = context.makeImage() {
                return UIImage(cgImage: contextImage)
            }

        }

        return nil
    }
}