laravel phpexcel更新中的模糊类分辨率 [英] Ambiguous class resolution in laravel phpexcel update

查看:515
本文介绍了laravel phpexcel更新中的模糊类分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



错误:

 警告:在

C:\xampp\中找到了不明确的类解析,SettingsController htdocs\mti\app\controllers\SettingsController.php和

C:\xampp\htdocs\mti\app\controllers\SettingsControllerBackup.php,第一个

将被使用。警告:模糊类解析,ClassModel都在

C:\xampp\htdocs\mti\app \models\ClassModel.php和C:\xampp\htdocs\mti\

app \models\LoginModel.php,第一个将被使用。

SettingsController:

 <?php 

class SettingsController extends BaseController
{

public function ChangePasswordLayout()
{
return View :: make('settings / changepassword / changepassword');
}

public function ChangePasswordProcess()
{
$ PasswordData = Input :: all();

Validator :: extend('pwdvalidation',function($ field,$ value,$ parameters)
{
return Hash :: check($ value,Auth :: user () - > password);
});

$ messages = array('pwdvalidation'=>'旧密码不正确');

$ validator = Validator :: make($ PasswordData,User :: $ rulespwd,$ messages);
if($ validator-> passed())
{
$ user = User :: find(Auth :: user() - > id);
$ user-> password = Hash :: make(Input :: get('NewPassword'));
$ user-> save();
返回Redirect :: to('changepassword') - > withInput() - > with('Messages','密码信息更新');
} else
{
return Redirect :: to('changepassword') - > withInput() - > withErrors($ validator);
}

}

public function ProfileLayout()
{
$ user = Auth :: user() - > id;
$ ProfileDetailsbyid = ProfileModel :: where('id',$ user) - > get() - > toArray();
return View :: make('settings / profile / profile') - > with('ProfileDetailsbyid',$ ProfileDetailsbyid);
}

public function ProfileUpdateProcess($ data = NULL)
{

$ user = Auth :: user() - > id;
$ ProfileDetailsbyid = ProfileModel :: where('id',$ user) - > get() - > toArray();

$ ProfileData = array_filter(Input :: except(array('_ token')));

$ validation = Validator :: make($ ProfileData,ProfileModel :: $ rules);
if($ validation-> passed())
{

if(!empty($ ProfileData ['Photo']))
{
Input :: file('Photo') - > move('assets / uploads / profilephoto /',$ user。'-Photo。'。Input :: file('Photo') - > getClientOriginalName());
$ Photo = $ user .'-照片。输入::文件(照片) - > getClientOriginalName();
unset($ ProfileData ['Photo']);
$ ProfileData ['Photo'] = $ Photo;
}

$ affectedRows = ProfileModel :: where('id',$ user) - > update($ ProfileData);
// VehicleModel :: create($ VehicleData);
返回Redirect :: to('profile') - >(('Message','Profile Details Update Succefully') - >('ProfileDetailsbyid',$ ProfileDetailsbyid)
} else
{

返回Redirect :: to('profile') - > withInput() - > withErrors($ validation-> messages()) - > with('ProfileDetailsbyid',$ ProfileDetailsbyid);
}
}


}

ClassModel:

 <?php 
class ClassModel extends Eloquent
{

protected $ primaryKey ='AutoID';
protected $ created_at ='CreatedAt';
protected $ updated_at ='UpdatedAt';
protected $ table ='class';
protected $ guarded = array('GradeName');
protected $ fillable = array('GradeName');

public function batch(){
return $ this-> hasMany('BatchModel','Class');
}

public function studentadmissionresult(){
return $ this-> hasMany('StudentAdmissionModel','StudentCourse');
}

public $ timestamps = true;



public static $ rules = array(
'GradeName'=> array('required','unique:class','regex:/ ^ 。$'$'$',
'
public static $ updaterules = array(
'GradeName'=> array('required','regex:/^./'),
'GradeSection'=>'required ,
'GradeCode'=> array('required')
);

}

我遵循本教程:



https://github.com/Maatwebsite/ Laravel-Excel



我尝试以下命令:

  composer require maatwebsite / excel:〜1.2.1 




解释方法

这与您正在安装的软件包无关。



在更新后重新创建自动加载文件( composer dump-autoload )Composer检测到您有两个具有完全相同名称的类(但在不同的文件中)。



SettingsController SettingsController.php SettingsControllerBackup.php



和class ClassModel ClassModel.php LoginModel.php



作曲家将选择使用两者之一(我不知道它是如何做出决定的,它可能只是第一个),并忽略其他事件。 p>

解决方案




  1. 删除不需要的文件

  2. 重命名课程

一个很好的常见做法是将类命名为该文件。这是避免这种冲突的一种简单方法,因为同一目录中的两个文件不能具有相同的名称。


I try to update the laravel with php excel while installing i found the below warning in the composer.

Error:

Warning: Ambiguous class resolution, "SettingsController" was found in both 

"C:\xampp\htdocs\mti\app\controllers\SettingsController.php" and 

"C:\xampp\htdocs\mti\app\controllers\SettingsControllerBackup.php", the first 

will be used.Warning: Ambiguous class resolution, "ClassModel" was found in both

"C:\xampp\htdocs\mti\app\models\ClassModel.php" and "C:\xampp\htdocs\mti\

app\models\LoginModel.php", the first will be used.

SettingsController:

<?php

class SettingsController extends BaseController
{

    public function ChangePasswordLayout()
    {
        return View::make('settings/changepassword/changepassword');
    }

    public function ChangePasswordProcess()
    {
        $PasswordData = Input::all();

        Validator::extend('pwdvalidation', function($field, $value, $parameters)
        {
            return Hash::check($value, Auth::user()->password);
        });

        $messages = array('pwdvalidation' => 'The Old Password is Incorrect');

        $validator = Validator::make($PasswordData, User::$rulespwd, $messages);
        if ($validator->passes()) 
        {
            $user = User::find(Auth::user()->id);
            $user->password = Hash::make(Input::get('NewPassword'));
            $user->save();
            return Redirect::to('changepassword')->withInput()->with('Messages', 'The Password Information was Updated');
        } else 
        {
            return Redirect::to('changepassword')->withInput()->withErrors($validator);
        }

    }

    public function ProfileLayout()
    {
        $user = Auth::user()->id;
        $ProfileDetailsbyid = ProfileModel::where('id', $user)->get()->toArray();   
        return View::make('settings/profile/profile')->with('ProfileDetailsbyid', $ProfileDetailsbyid);
    }

    public function ProfileUpdateProcess($data=NULL)
    {

    $user = Auth::user()->id;
    $ProfileDetailsbyid = ProfileModel::where('id', $user)->get()->toArray();

        $ProfileData = array_filter(Input::except(array('_token')));

      $validation  = Validator::make($ProfileData, ProfileModel::$rules);        
        if ($validation->passes()) 
        {

        if(!empty($ProfileData['Photo']))
    {
    Input::file('Photo')->move('assets/uploads/profilephoto/', $user . '-Photo.' . Input::file('Photo')->getClientOriginalName());
    $Photo=$user.'-Photo.' . Input::file('Photo')->getClientOriginalName();
    unset($ProfileData['Photo']);
    $ProfileData['Photo']=$Photo;
    }

           $affectedRows = ProfileModel::where('id', $user)->update($ProfileData);
            //VehicleModel::create($VehicleData);
            return Redirect::to('profile')->with('Message', 'Profile Details Update Succesfully')->with('ProfileDetailsbyid', $ProfileDetailsbyid);
        } else 
        {

            return Redirect::to('profile')->withInput()->withErrors($validation->messages())->with('ProfileDetailsbyid', $ProfileDetailsbyid);
        }
    }


}

ClassModel:

<?php
class ClassModel extends Eloquent
{

    protected $primaryKey = 'AutoID';
    protected $created_at = 'CreatedAt';
    protected $updated_at = 'UpdatedAt';
    protected $table = 'class';
    protected $guarded = array('GradeName');
    protected $fillable = array('GradeName');

    public function batch(){
        return $this->hasMany('BatchModel', 'Class');
    }

    public function studentadmissionresult(){
        return $this->hasMany('StudentAdmissionModel', 'StudentCourse');
    }

    public $timestamps = true;



    public static $rules = array(
        'GradeName' =>  array('required', 'unique:class','regex:/^./'),
        'GradeSection' => 'required',
        'GradeCode' => array('required', 'unique:class')
                             );
     public static $updaterules = array(
        'GradeName' =>  array('required','regex:/^./'),
        'GradeSection' => 'required',
        'GradeCode' => array('required')
                             );                      

}

I following this tutorial:

https://github.com/Maatwebsite/Laravel-Excel

I have try following command :

composer require maatwebsite/excel": "~1.2.1

解决方案

This actually has nothing to do with the package you are installing.

Explanation

When recreating the autoload files (composer dump-autoload) after the update Composer detected that you have two classes with the exact same name (but in different files).

Class SettingsController in SettingsController.php and SettingsControllerBackup.php

and class ClassModel in ClassModel.php and LoginModel.php

Composer will then choose to use one of the two (I'm not sure how it makes that decision, it's probably just the first one it finds) and will ignore the other occurrence.

Solutions

  1. Delete the files if you don't need them
  2. Rename the class

A good and common practice is to name the class like the file. This is a simple way to avoid such collisions because two files in the same directory can't have the same name.

这篇关于laravel phpexcel更新中的模糊类分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆