Ambiguous class resolution in laravel phpexcel update

I am trying to update laravel with php excel during installation, I found below warning in 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 follow this guide:

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

I will try to execute the command:

 composer require maatwebsite/excel": "~1.2.1 
+5
source share
1 answer

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

Description

When updating startup files ( composer dump-autoload ) after updating, Composer found that you have two classes with the same name (but in different files).

SettingsController class in SettingsController.php and SettingsControllerBackup.php

and class ClassModel in ClassModel.php and LoginModel.php

Then the composer will use one of the two (I'm not sure how he makes this decision, perhaps only the first thing he finds) and ignores the other event.

Decision

  • Delete files if you do not need them.
  • Rename class

It is good and common practice to name a class similar to a file. This is an easy way to avoid such collisions, because two files in the same directory cannot have the same name.

+6
source

Source: https://habr.com/ru/post/1211052/


All Articles