小编Mig*_*ges的帖子

使用jQuery Validation插件的Bootstrap

我正在尝试使用jQuery Validation Plugin为我的表单添加验证,但是我遇到了一个问题,当我使用输入组时插件会输出错误消息.

问题

$('form').validate({
    rules: {
        firstname: {
            minlength: 3,
            maxlength: 15,
            required: true
        },
        lastname: {
            minlength: 3,
            maxlength: 15,
            required: true
        }
    },
    highlight: function(element) {
        $(element).closest('.form-group').addClass('has-error');
    },
    unhighlight: function(element) {
        $(element).closest('.form-group').removeClass('has-error');
    }
});
Run Code Online (Sandbox Code Playgroud)

我的代码: http ://jsfiddle.net/hTPY7/4/

jquery-validate twitter-bootstrap twitter-bootstrap-3

151
推荐指数
6
解决办法
19万
查看次数

使用env('APP_ENV'),config('app.env')或App :: environment()来获取应用环境有什么区别?

是用什么区别env('APP_ENV'),config('app.env')或者App::environment()导致某些应用环境?

我知道env('APP_ENV')意志$_ENV,config('app.env')读取配置,App::environment()是所有的抽象.在我看来,优势甚至是这个.抽象.

我不知道是否存在其他差异,例如性能水平或安全性

environment-variables laravel laravel-5 phpdotenv

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

如何在laravel 4中自动加载'图书馆'?

我在app文件夹中创建了一个库文件夹来添加我的应用程序库.我已经更新了应用程序配置文件和composer.json以自动加载该文件夹,但是当我运行该命令时,composer dump-autoload我得到了下一个错误:

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'App\\Libraries\\Search\\SearchServiceProvider' not found","file":"D:\\Users\\Miguel Borges\\Documents\\Trabalhos\\Tese\\portal\\bootstrap\\compiled.php","line":4130}}PHP Fatal error: Class 'App\Libraries\Search\SearchServiceProvider' not found in D:\Users\Miguel Borges\Documents\Trabalhos\Tese\portal\bootstrap\compiled.php on line 4130 [Finished in 1.1s with exit code 255]

我的app文件夹树:

app
| ...
+ libraries
| + search
| | - Search.php
| | - SearchFacade.php
| | - SearchServiceProvider.php
| + lib2
| | - ...
| + lib3
| | - ...
| | - Theme.php
| - ...
- filters.php
- routes.php
Run Code Online (Sandbox Code Playgroud)

SearchServiceProvider.php

namespace App\Libraries\Search;

use Illuminate\Support\ServiceProvider;

class …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-4

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

Lumen 5.2+的观点

我需要构建一个小小部件,并计划使用Lumen,因为我需要快速响应,我需要路由,翻译,请求和视图等组件.现在注意到问题已经在版本5.1之后停止了.

是否可以在更新版本的Lumen中使用视图?

laravel lumen lumen-5.3 laravel-views

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

将文字设置为谷歌+分享按钮

我正在创建一个具有g + share按钮的页面,但我想动态更改要共享的内容的描述.自定义共享按钮我正在使用Open Graph协议的代码段.

我尝试的解决方案如下,但它无法正常工作:

<meta property="og:title" content="O Fabuloso Gerador De Lero Lero v3" />
<meta property="og:image" content="images/robot.png" />
<meta property="og:description" content="..." />
Run Code Online (Sandbox Code Playgroud)
$('meta[property="og:description"]').attr('content',text);

var shareButtons = $('div:first','section.share-buttons');
shareButtons.html('');
shareButtons
    .prepend('<a href="https://twitter.com/share" class="twitter-share-button" data-text="' + text.trunc(120,true) + '" data-url="http://goo.gl/1KHFM" data-lang="pt">Tweetar</a>')
    .prepend('<div class="g-plus" data-action="share" data-href="http://lerolero.miguelborges.com/t=' + new Date().getTime() + '" data-annotation="bubble"></div>');

try {
    window.twttr.widgets.load();
    window.gapi.plus.go();
} catch(e) {}
Run Code Online (Sandbox Code Playgroud)

但是,分享按钮中的描述内容始终是初始的.

有谁知道如何使它工作?

编辑:

按钮twitte我有同样的问题,但设法解决这个问题:

        shareButtons
            .prepend('<a href="https://twitter.com/share" class="twitter-share-button" data-text="' + text.trunc(120,true) + '" data-url="http://goo.gl/1KHFM" data-lang="pt">Tweetar</a>');

        window.twttr.widgets.load();
Run Code Online (Sandbox Code Playgroud)

javascript share code-snippets opengraph google-plus

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

带有页眉和页脚的listview

我正在尝试构建一个Android视图,其中listview作为页眉和页脚.到目前为止只管理只出现在标题中.这是一张图片,解释了我想要的和我所拥有的.

尝试

有谁知道我做错了什么?干掉当前代码:

<?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#ffffff">

<!--  Header Starts-->
<LinearLayout android:id="@+id/header" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:background="@layout/header_gradient" 
        android:layout_margin="5dip" 
        android:paddingTop="13dip" 
        android:paddingBottom="8dip">
    <!-- Logo Start-->
    <ImageView android:src="@drawable/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" />
    <!-- Logo Ends -->
</LinearLayout>
<!--  Header Ends -->

<!-- Content -->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:layout_height="fill_parent"
              android:layout_width="fill_parent"
              android:orientation="vertical"
              android:gravity="center">

        <LinearLayout android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dip">

            <EditText android:id="@+id/searchText"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"/>

            <ImageButton android:id="@+id/searchButton"
                    android:layout_height="wrap_content" 
                    android:layout_width="wrap_content" 
                    android:src="@android:drawable/ic_menu_search" />
        </LinearLayout> 

        <ListView android:id="@+id/lstNews" 
                android:layout_height="fill_parent"
                android:layout_width="fill_parent"
                android:layout_marginLeft="5dip"
                android:layout_marginRight="5dip" />
    </LinearLayout>

<!-- Footer Start -->
<LinearLayout android:id="@+id/footer" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-listview

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

添加模型关系而不保存

我有下一个恋爱关系User hasMany Contacts。在正常情况下,使用$user->contacts()->save($contact)可以将联系人添加并保存到用户,但是我需要在不保存模型(用户和联系人)的情况下将联系人与用户相关联。

编辑:

我需要建立一个可以接收其中一种方法并返回XML模板集合的工厂,只有在其中一些模型中才会存储在postiriori中。

php laravel eloquent laravel-4

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

SQLite无法打开数据库文件:Laravel + Windows

我尝试在我的laravel项目中使用sqlite数据库,在dev的本地环境中使用(带有AMMPS的Windows 8.1),但是当我尝试运行migrate:instal命令时,这个错误最终:

[PDOException] SQLSTATE [HY000] [14]无法打开数据库文件

我的数据库配置文件(app/config/local/database.php):

<?php

return array(
    'default' => 'sqlite',

    'connections' => array(
        'sqlite' => array(
            'driver'   => 'sqlite',
            'database' => __DIR__ . '\..\..\database\production.sqlite',
            'prefix'   => '',
        ),
    ),
);
Run Code Online (Sandbox Code Playgroud)

php sqlite laravel laravel-4 artisan

4
推荐指数
2
解决办法
9843
查看次数

带引导程序的缩略图库

我正在尝试使用 twitter bootstrap 制作缩略图库(2x2),但没有得到预期的效果。在每一行的第一个缩略图中,从第 2 行开始,应用于左边距,使其每行只适合一个图像。

问题

编码:

    <div class="row-fluid">
        <div class="span6">
            <h2 id="clients">Clients</h2>

            <div class="row-fluid">
                <ul class="thumbnails">
                    <li class="span6">
                        <a href="#" class="thumbnail"><img src="http://placehold.it/220x100" alt=""></a>
                    </li>
                    <li class="span6">
                        <a href="#" class="thumbnail"><img src="http://placehold.it/220x100" alt=""></a>
                    </li>
                    <li class="span6">
                        <a href="#" class="thumbnail"><img src="http://placehold.it/220x100" alt=""></a>
                    </li>
                    <li class="span6">
                        <a href="#" class="thumbnail"><img src="http://placehold.it/220x100" alt=""></a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="span6">
            <h2 id="testiominals">Testemunhos</h2>

            <blockquote>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
                <small>Someone famous <a href=""><cite title="Source Title">Source Title</cite></a></small>
            </blockquote>

            <blockquote>
                <p>Lorem …
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap

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

如何更改laravel日志格式?

我需要将 Laravel 日志的格式更改为 json 格式,如下所示:

{
   "time":"2015-10-06 15:45:36",
   "host":"192.000.000",
   "protocol”:”http, tcp",
   "remote-addrress": "192.000.001",
   "user":"user-logged",
   "level": "warning",
   "message":"exception",
}  
Run Code Online (Sandbox Code Playgroud)

这该怎么做?

我尝试将下一个代码放在 bootstrap/app.php 中,但我不知道如何更改 json 格式/对象。

$app->configureMonologUsing(function ($monolog) use ($app) {
    // Stream handlers
    $logPath = $app->storagePath().'/logs/test.log';
    $logLevel = \Monolog\Logger::DEBUG;

    $logStreamHandler = new \Monolog\Handler\StreamHandler($logPath, $logLevel);

    $formatter = new \Monolog\Formatter\JsonFormatter();
    $logStreamHandler->setFormatter($formatter);
    $monolog->pushHandler($logStreamHandler);
});
Run Code Online (Sandbox Code Playgroud)

这是结果:

{
   "message":"info",
   "context":[
   ],
   "level":200,
   "level_name":"INFO",
   "channel":"local",
   "datetime":{
      "date":"2016-09-22 10:33:38.318064",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "extra":[

   ]
}
Run Code Online (Sandbox Code Playgroud)

php logging laravel laravel-5 laravel-5.2

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