11

我尝试在安装时使用 php excel 更新 laravel,我在作曲家中发现了以下警告。

错误:

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.

设置控制器:

<?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);
        }
    }


}

类模型:

<?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')
                             );                      

}

我遵循本教程:

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

我尝试了以下命令:

composer require maatwebsite/excel": "~1.2.1
4

1 回答 1

17

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

解释

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

上课和SettingsController_SettingsController.phpSettingsControllerBackup.php

和上课ClassModel_ClassModel.phpLoginModel.php

然后 Composer 将选择使用两者之一(我不确定它是如何做出这个决定的,它可能只是它找到的第一个)并且会忽略另一个事件。-确认。Composer 使用 first match

解决方案

  1. 如果不需要,请删除文件
  2. 重命名类

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

于 2015-01-14T07:47:11.410 回答