小编Dol*_*rma的帖子

LARAVEL在视图中获得withErrors的结果

在我正在使用的控制器中:

if ($validator->fails())
{
   return Redirect::to('/admin/profile')
    ->withErrors($validator)
    ->withInput();
}
Run Code Online (Sandbox Code Playgroud)

如何在视图中获得withErrors的结果?

{{ $errors->all() }}
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-4

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

Laravel对save()的中等错误

在下面的示例代码中,我将如何调节Eloquent无法保存或更新字段或断开SQL连接等错误?

$user = new User;

$user->name = 'John';

$user->save();
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-4

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

Android为自定义TextView小部件设置字体

我写了简单的小部件作为textview与一些属性,我想在扩展的TextView类中设置字体,如何做这个动作,我可以有这种能力?

atributes:

<resources>
    <declare-styleable name="TextViewStyle">
       <attr name="selected_background" format="integer" />
       <attr name="font"                format="string" />
    </declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)

自定义textview小部件:

public class TextViewStyle extends TextView{

    public TextViewStyle(Context context) {
        super(context);
    }
    public TextViewStyle(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TextViewStyle(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewStyle, defStyle, 0);

        a.recycle();
    }
}
Run Code Online (Sandbox Code Playgroud)

简单的UI小部件到xml:

<ir.jaziire.widgets.TextViewStyle
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/topic"
    android:textColor="#000"
    android:textSize="14dp"
    android:gravity="right"
    />
Run Code Online (Sandbox Code Playgroud)

在这个小部件中,我想设置app:font=""为从资产设置任何字体

android android-widget

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

Android传递View作为片段的对象

我更google搜索我怎样才能将简单view的对象传递给片段,但我不能.

例如在MainActivity中,我有一个简单的视图:

TextView text = (TextView) findviewById(R.id.tv_text);
Run Code Online (Sandbox Code Playgroud)

现在我想把它传递给片段.下面的代码是我在MainActivity上的附加片段

MainActivity :

public void attachFragment() {
    fts = getActivity().getFragmentManager().beginTransaction();
    mFragment = new FragmentMarketDetail();
    fts.replace(R.id.cardsLine, mFragment, "FragmentMarketDetail");
    fts.commit();
}
Run Code Online (Sandbox Code Playgroud)

这是我的Fragment:

public class FragmentMarketDetail extends Fragment implements ObservableScrollViewCallbacks {
    public static final String SCROLLVIEW_STATE = "scrollviewState";
    private ObservableScrollView scrollViewTest;
    private Context    context;
    private int scrollY;

    public static FragmentMarketDetail newInstance() {
        FragmentMarketDetail fragmentFirst = new FragmentMarketDetail();
        return fragmentFirst;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

3
推荐指数
2
解决办法
3208
查看次数

Laravel 在单个子句中使用多个 where 和 sum

在我的数据库中,我有instagram_actions_histories一个表,其中有action_type一个列,在该列中我有不同的数据,例如123

例如,我正在尝试获取此表数据的关系并对存储在列中的值求和

$userAddedPagesList = auth()->user()->instagramPages()->with([
        'history' => function ($query)  {
            $query->select(['action_type as count'])->whereActionType(1)->sum('action_type');
        }
    ]
)->get();
Run Code Online (Sandbox Code Playgroud)

顺便说一句,这段代码不正确,因为我想获得其中history包含多个的所有内容sum

whereActionType(1)->sum('action_type')
whereActionType(2)->sum('action_type')
whereActionType(3)->sum('action_type')
Run Code Online (Sandbox Code Playgroud)

例如(伪代码):

$userAddedPagesList = auth()->user()->instagramPages()->with([
        'history' => function ($query)  {
            $query->select(['action_type as like'])->whereActionType(1)->sum('action_type');
            $query->select(['action_type as follow'])->whereActionType(2)->sum('action_type');
            $query->select(['action_type as unfollow'])->whereActionType(3)->sum('action_type');
        }
    ]
)->get();
Run Code Online (Sandbox Code Playgroud)

更新

$userAddedPagesList = auth()->user()->instagramPages()->with([
        'history' => function ($query) {
            $query->select('*')
                ->selectSub(function ($query) {
                    return $query->selectRaw('SUM(action_type)')
                        ->where('action_type', '=', '1');
                }, 'like')
                ->selectSub(function ($query) {
                    return $query->selectRaw('SUM(action_type)')
                        ->where('action_type', …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5.6

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

Ubuntu 在路径上设置后获取模块 java.se.ee

我得到java.lang.module.FindException: Module java.se.ee not found的错误,当我尝试更新Android SDK中我把这个路径/etc/environment

JAVA_HOME="/usr/lib/jvm/java-12-oracle"
export JAVA_HOME
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
export SDKMANAGER_OPTS='--add-modules java.se.ee'
Run Code Online (Sandbox Code Playgroud)

并在运行此命令后:

source /etc/environment
Run Code Online (Sandbox Code Playgroud)

我在终端上没有收到任何消息,现在这个命令:

sudo /usr/lib/android-sdk/tools/bin/sdkmanager --update
Run Code Online (Sandbox Code Playgroud)

告诉我这个错误:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found
Run Code Online (Sandbox Code Playgroud)

更新:

我安装 OpenJDK

$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1-b01)
OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode)
Run Code Online (Sandbox Code Playgroud)

设置为默认值后,我也收到错误

错误:无法找到或加载主类 java.se.ee

重新启动 ubuntu - 终端和source /etc/environment命令无法解决我的问题

DEFAULT_JVM_OPTS 关于 sdkmanager 文件内容:

#DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
Run Code Online (Sandbox Code Playgroud)

java ubuntu

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

Flutter为ScaleTransition设置自定义限制

在此示例代码中,当我尝试缩放图标时,我想将图标大小限制ScaleTransition为 10% ,但我无法这样做来对图标进行此限制zoom-inzoom-out

import 'package:flutter/material.dart';
import 'package:flutter/animation.dart';

void main() => runApp(MyApp());

class ScaleTransitionExample extends StatefulWidget {
  _ScaleTransitionExampleState createState() => _ScaleTransitionExampleState();
}

class _ScaleTransitionExampleState extends State<ScaleTransitionExample> with TickerProviderStateMixin {
  AnimationController _controller;
  Animation<double> _animation;

  initState() {
    super.initState();
    _controller = AnimationController(duration: const Duration(milliseconds: 2000), vsync: this);
    _animation = CurvedAnimation(parent: _controller, curve: Curves.ease);
    _controller.forward();
  }

  @override
  dispose() {
    _controller.dispose();
    super.dispose();
  }

  Widget build(BuildContext context) {
    return Container(
        color: Colors.white,
        child: Stack(
          children: <Widget>[
            Center(
              child: ScaleTransition(
                  scale: _animation,
                  alignment: Alignment.center, …
Run Code Online (Sandbox Code Playgroud)

flutter

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

Flutter制作简单的渐变阴影

我想构建一个渐变阴影小部件,如下所示。

在此输入图像描述

这个渐变从黑色开始到白色结束,我该如何设计这种类型的小部件?

dart flutter

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

Dart 如何制作 MyClass.of(context) 方法

假设我有这门课:

class AppTheme {
  final BuildContext context;

  AppTheme(this.context);

  TextStyle caption() {
    return Theme.of(context).textTheme.caption.copyWith(
      color: Colors.black
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

如何以可以使用以下方式访问的方式修改它caption

AppTheme.of(context).caption();
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

Flutter Container 变换(动画包)

随机地,当我看到 flutter 包和库时,我发现了flutteranimations ,并且我看到,有一个非常有用的动画Gmail,例如具有搜索导航动画的 Android 应用程序。要理解我的意思,您可以查看此链接,第 4 号动画

我在 github 上的存储库中查看了此包的源文件夹,但我找不到此动画的示例实现,并且我不确定是否有示例代码,有人可以帮助我如何使用它吗Container transform

flutter flutter-animation

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