标签: laravel-5

如何在Laravel 5中通过ajax上传文件

我使用了jQuery-File-Upload插件(https://github.com/blueimp/jQuery-File-Upload),但没有用.这是我的HTML:

<!-- The fileinput-button span is used to style the file input field as button -->
    <span class="btn btn-success fileinput-button">
            <i class="glyphicon glyphicon-plus"></i>
            <span>Add files...</span>
            <!-- The file input field used as target for the file upload widget -->
            <input id="fileupload" type="file" name="files[]" multiple>
            <input type="hidden" class="hidden-token" name="_token" value="{!! csrf_token() !!}">
        </span>
    <br>
    <br>
    <!-- The global progress bar -->
    <div id="progress" class="progress">
        <div class="progress-bar progress-bar-success"></div>
    </div>
    <!-- The container for the uploaded files -->
    <div id="files" class="files"></div> …
Run Code Online (Sandbox Code Playgroud)

php ajax jquery laravel-5

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

如何使用Eloquent ORM Laravel创建基于条件的查询?

如果这样的条件,我可以使用此代码吗?

$testq= DB::table('attendances')
    if($flag==1)
    ->where('type', '=', $userinput)
    else
    ->where('type', '=', $newdate)
    ->get();
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent laravel-5

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

我如何在迁移中删除表的外键和主键?

我如何在迁移文件中删除多个外键和主键.

Bellow是我的迁移文件代码.

迁移文件

public function up()
{
    Schema::create('role_user', function(Blueprint $table){
        $table->integer('role_id')->unsigned();
        $table->integer('user_id')->unsigned();

        $table->foreign('role_id')
                ->references('id')
                ->on('roles')
                ->onDelete('cascade');

        $table->foreign('user_id')
                ->references('id')
                ->on('users')
                ->onDelete('cascade');

        $table->primary(['role_id', 'user_id']);
    });
}
public function down()
{
    Schema::drop('role_user');
    //how drop foreign and primary key here ?
}
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.5

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

如何在Laravel 5中显示计数数据

我是Laravel的新手,5小时我试图添加这个功能,我很困惑. 案例: 我想tb_surat在仪表板(我使用sximo)ex中显示表中的计数数据,如果tb_surat我有12行数据.如何显示这个像 "总数据:12"

请帮助我,一步一步地给我添加控制器或查看或路线等,我不明白.谢谢.

php laravel laravel-5

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

无法在ubuntu中执行laravel命令,并且无法在home/<user>目录中找到.composer文件夹

一旦我有作曲家的错误,所以我卸载并删除.composer文件夹.现在我再次安装了composer,但是无法创建.composer文件夹.如果无法创建.composer文件夹,我无法全局运行Laravel.请帮我解决一下这个.在此输入图像描述

php laravel composer-php laravel-5 laravel-5.2

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

如何在laravel 5.2中使用邮件功能?

我已经尝试过在laravel中使用邮件功能,但没有成功。建议我如何在laravel中发送电子邮件。这是我在Controller中的代码。

 $Body = "$CusName ($UID - $CusEmail ) from $SiteID";

 $param = array('User'=>$Use, 'Pass'=>$Pass,'Body'=>$Body,'SiteID'=>$SiteID);
 $Email['To']="xyz@gmail.com";
 $Email['Sender']=$CusEmail;
 $Email['Body']=$data;

 $mail= mail("xyz@gmail.com","My subject",$data);
Run Code Online (Sandbox Code Playgroud)

谢谢

php laravel laravel-5 laravel-5.2

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

每个周末都要运行Laravel时间表

任何人都可以告诉我,我需要在Laravel 5.4中创建一个自动运行的程序.

首先,我创建了一个文件FollowAdvisor.php at/app/Console/Commands/

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use DB;

class FollowAdvisor extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'follow:advisor';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-5 laravel-5.4

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

pluck('id')将字符串值转换为零

我有一个表的主键string类型存储uuid值.当我查询数据时一切都很好.但是当我pluck('id')用来获取所有id的数组时,我得到了一些零!我试着测试它,pluck('firstName')它返回名字数组.当我替换'firstName''id'I时,得到零值数组.

pluck会自动将id值转换为int?这有解决方法吗?

我使用Laravel 5.5

$p = \App\Profile::all()->take(5)
=> Illuminate\Database\Eloquent\Collection {#1015
     all: [
       App\Profile {#980
         id: "client.121138f1-e999-35a1-a16",
         phone: "496.533.3798",
         firstName: "Gabriella",
         lastName: "Steuber",
         company: "",
         email: "tyra.raynor@example.com",
         city_id: 1,
         address: """
           353 Nolan Stravenue\n
           Gudrunshire, MN 36601-6307
           """,
         isCompany: 0,
         status: 1,
         state: "active",
         role: "client",
         created_at: "2017-11-05 11:59:49",
         updated_at: "2017-11-05 11:59:49",
         deleted_at: null,
       },
       App\Profile {#1004
         id: "client.1eac4f8c-e020-31df-96c",
         phone: "290.757.1167 x",
         firstName: "Yadira",
         lastName: "Dietrich",
         company: …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent laravel-5 laravel-5.5

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

添加 Blade php 页面的链接

我为我的应用程序开发了几个页面。现在我需要添加这些页面的链接。到目前为止,我都是通过 url 浏览打开这些页面。

我的 web.php 页面

// for books
Route::get('/book','BookController@create');
Route::post('/book','BookController@store');
Route::get('/book/{id}','BookController@edit');
Route::patch('/book/{id}', 'BookController@update');

// for ordered books
Route::get('/order','OrderedBookController@create');
Route::post('/order','OrderedBookController@store');
Route::get('/billSearch','OrderedBookController@searchBill');
Route::post('/billSearch','OrderedBookController@billPay');
Route::post('/billSearch/{id}', 'OrderedBookController@pay');

// for Books Out
Route::get('/booksout','BooksOutController@create');
Route::post('/booksout','BooksOutController@store');
Run Code Online (Sandbox Code Playgroud)

路线对应的页面列表

book.blade.php
edit.blade.php
booksin.blade.php
booksout.blade.php
Run Code Online (Sandbox Code Playgroud)

浏览这些页面的本地主机 URL 是::

http://127.0.0.1:8000/book
http://127.0.0.1:8000/order
http://127.0.0.1:8000/billSearch // for Route::get('/billSearch','OrderedBookController@searchBill');
http://127.0.0.1:8000/booksout
Run Code Online (Sandbox Code Playgroud)

由于我是通过路线而不是页面浏览页面,如何在网络应用程序中创建链接?

php laravel laravel-5 laravel-blade

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

如何在 Laravel 中将参数传递给 whereHas() 子句

我查询了 Category 模型以获取用于查询 Post 模型的所有 id 'name', '=', $name,但出现错误。

public function getList($name)
{
    $category_id = Category::where('name', '=', $name)->first()->id;

    $posts = Post::whereHas('category', function ($q) use ($category_id) {
        $q->where('id', '=', $category_id);
    })->paginate(12);

    return view('blog.index')->withPosts($posts)->withName($name);
}
Run Code Online (Sandbox Code Playgroud)

这是我的错误。

Builder.php 第 877 行中的 ErrorException:compact():未定义的变量:运算符

laravel eloquent laravel-5

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