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,
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 {
...
}
No error = perfect. 10x for the logic, I knew it was something, that I was missing.
I've added additional use \Auth; under.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community