Support the ongoing development of Laravel.io →
Configuration Eloquent Architecture

Hi,

I've added a custom classes to ...app/classes/... using a tutorial I've read and so far so good - Added the classes to be loaded within .../config/app.php

'Calendar' => 'Calendar\Calendar',
'EmbedEmbed' => 'Calendar\EmbedEmbed',
'BBCodeFormater' => 'Calendar\BBCodeFormater',

Model: - Kalendar.php

class Kalendar extends Eloquent {

protected $connection = 'mysql'; // static 
protected $table = 'calendar';
protected $primaryKey = 'id'; ... }

CalendarController.php

...
$calendar = new Calendar\Calendar();
...

Everything is fine until, I change the query in the .../app/classes/Calendar/Calendar.php

<?php namespace Calendar;

class Calendar {

...

public function __construct($condition=false) /*$db_server, $db_username, $db_password, $db_name, $table,*/ 
		{
			
			$this->condition = $condition;
			
			// Run The Query
			if($condition == false) // $this->condition == false
			{
				$query = User::find(Auth::user()->username)->calendar; // $this->result =
				//mysqli_query($this->connection, "SELECT * FROM $this->table ");
			} else {
				$query = User::find(Auth::user()->username)->calendar; // $this->result = 
				//mysqli_query($this->connection, "SELECT * FROM $this->table WHERE $this->condition");	
			}
			
		}


...

It provides me the following error:


Class 'Calendar\User' not found, pointing to:
$query = User::find(Auth::user()->username)->calendar;

Any advice would be of great help. Tried googling it, but either I don't know how to search it.

Thanks in advance,

Last updated 3 years ago.
0
Solution

I think your User class is in Calendar namespace.

Try put use \User at top and see if it works.

<?php namespace Calendar;

use \User;

class Calendar {
  ...
}

Last updated 10 years ago.
0

No error = perfect. 10x for the logic, I knew it was something, that I was missing.

I've added additional use \Auth; under.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

goranata goranata Joined 12 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.