Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果记录存在,则禁用laravel 5.4中的按钮_Javascript_Php_Laravel_Laravel 5_Laravel 5.3 - Fatal编程技术网

Javascript 如果记录存在,则禁用laravel 5.4中的按钮

Javascript 如果记录存在,则禁用laravel 5.4中的按钮,javascript,php,laravel,laravel-5,laravel-5.3,Javascript,Php,Laravel,Laravel 5,Laravel 5.3,如果在我的用户表中注册了一个用户,我会尝试禁用一个按钮,但使用我使用的方法不会禁用我想要禁用的按钮,而是将其禁用到所有寄存器 这是我的用户迁移: public function up() { Schema::create('users', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->i

如果在我的用户表中注册了一个用户,我会尝试禁用一个按钮,但使用我使用的方法不会禁用我想要禁用的按钮,而是将其禁用到所有寄存器

这是我的用户迁移:

public function up()
{ 
    Schema::create('users', function (Blueprint $table) {
        $table->engine = 'InnoDB';
        $table->increments('id');
        $table->integer('id_employee')->unsigned();
        $table->string('username')->unique();//Cedula
        $table->string('name')->nullable();
        $table->string('password', 60)->nullable();
        $table->string('email', 60)->nullable();
        $table->rememberToken();
        $table->timestamps();                  
        $table->foreign('id_employee')->references('id')->on('employees')
              ->onUpdate('cascade')->onDelete('cascade');
    });
}
这是我的用户模型:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Employee extends Model
{
    protected $table = 'employees';

    protected $fillable = ['doc_number', 'user_code', 'name', 'last_name', 'settlement', 'address', 'city' , 'zip_code', 'email', 'phone', 'position', 'departments_id', 'hire_date'];

    protected $guarded = ['id'];

    public function departments()
    {
        return $this->belongsTo('App\Department');
    }

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

    //Query para buscador
    public function scopeName($query, $name)
    {
      $query->leftJoin('departments','employees.departments_id','=','departments.id')
            ->select('employees.*','departments.id as deptID','departments.name as department')
            ->where('employees.name','like',"%$name%")
            ->orWhere('employees.last_name','like',"%$name%")
            ->orWhere('employees.position','like',"%$name%")
            ->orWhere('employees.email','like',"%$name%")
            ->orWhere('employees.doc_number','like',"%$name%")              
            ->orWhere('departments.name','like',"%$name%"); 
    }
}
这是我的刀片视图和按钮:

<td>
    <div class="btn-group">                                     
        @if(count($users) === 0)
        <a href="{{ URL::route('padron.create', $employee->id) }}" type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" rel="tooltip" data-placement="top" title="Confirmar votante">Confirmar</a>

        @else
            <a type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" rel="tooltip" data-placement="top" disabled="disabled" title="Confirmar votante">Confirmar</a>

        @endif
    </div>
</td>

@if(计数($users)==0)
@否则
确认人
@恩迪夫

用简单的英语,您的逻辑是,如果没有用户,则显示按钮,否则禁用按钮。似乎您有
用户
,因此if总是失败,而else起作用

如果要禁用单个按钮的“confirmar”,则必须在某个位置使用用户id。差不多

@if($employee->id == ...) 
// depending on your logic

在简单的英语中,您的逻辑是,如果没有用户,则显示按钮,否则禁用按钮。似乎您有
用户
,因此if总是失败,而else起作用

如果要禁用单个按钮的“confirmar”,则必须在某个位置使用用户id。差不多

@if($employee->id == ...) 
// depending on your logic
  • 在控制器函数中使用成功的return语句发送一个值
  • 并使用此选项检查视图中是否存在该值
  • 在控制器函数中使用成功的return语句发送一个值
  • 并使用此选项检查视图中是否存在该值

  • 你的目的似乎不明确。是否要为登录用户禁用表单?是否仅对未注册/未登录的用户启用此按钮?如果我的用户表中有这些记录之一,我想禁用此按钮。请使用
    auth()
    auth
    查看所需内容,并将其与用户表中的数据进行比较。您的目的似乎不明确。是否要为登录用户禁用表单?并且仅对未注册/未登录的用户启用该按钮?如果我的用户表中有这些记录之一,我想禁用该按钮。请使用
    auth()
    auth
    检查您想要的内容,并将其与用户表中的数据进行比较。谢谢,但我不想确认来自员工表的信息,在users表中,会出现一个创建员工用户的流程。如果创建了此用户,则必须禁用该按钮。谢谢,但我要确认的不是员工表,而是用户表,而是有一个创建员工用户的过程。如果创建了此用户,则必须禁用该按钮。