Error Class App Http Controllers Model not found

0 votes

I want to use Model functions in view

My controller function code:

 $model = Model::find(1);
 View::make('view')->withModel($model);

 return view('index.search', ['tickets' => $result]);

My model code:

<?php

namespace App;
namespace App\models;
use Illuminate\Database\Eloquent\Model;

class Tickets extends Model
{
    public function someFunction() {
        echo 'hello world!';
    }
}

My view code:

{{ $model->someFunction() }}
Sep 11, 2020 in Laravel by kartik
• 37,520 points
5,229 views

1 answer to this question.

0 votes

Hello @kartik,

You need to import your model like this:

use App\Tickets;

right after line with namespace so it should look something like this:

<?php

namespace App\Http\Controllers;

use App\Tickets;

Hope it helps!!

Thank you!!

answered Sep 11, 2020 by Niroj
• 82,840 points

Related Questions In Laravel

+1 vote
1 answer

Error:Class '\App\User' not found in Laravel when changing the namespace in Laravel?

Hello @kartik Go to config/auth.php and change App\User:class ...READ MORE

answered Apr 3, 2020 in Laravel by Niroj
• 82,840 points
30,165 views
0 votes
1 answer

Error: Class 'TestCase' not found in D:\xampp\htdocs\laravel\app\tests\ExampleTest.php on line 3 ,

Hello @kartik, Run following command in your project's ...READ MORE

answered Sep 28, 2020 in Laravel by Niroj
• 82,840 points
2,260 views
0 votes
1 answer

Artisan migration error “Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found”?

Hello @kartik, This message shows up if you ...READ MORE

answered Apr 6, 2020 in Laravel by Niroj
• 82,840 points
5,762 views
0 votes
1 answer

Error: Class 'SoapClient' not found in /home/user/mysite.com/path/to/file.php on line 16

Hello @kartik, find this line in php.ini : ;extension=soap then ...READ MORE

answered Oct 29, 2020 in Laravel by Niroj
• 82,840 points
3,386 views
0 votes
1 answer

Why it is necessary to refresh CSRF token per form request?

Hello, Generating a new CSRF token for each ...READ MORE

answered Mar 19, 2020 in Laravel by Niroj
• 82,840 points
4,559 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,261 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
1,295 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,357 views
0 votes
2 answers

Error:Class 'App\Http\Controllers\App\Model' not found?

Class ‘App\Http\Controllers\Auth’ Not Found in Class ‘App\Http\Controllers\Auth’ not ...READ MORE

answered Aug 6, 2020 in Laravel by pakainfo
17,606 views
0 votes
1 answer

Fatal error: Class 'App\Http\Controllers\Redirect' not found

Hello @kartik, The only thing that you have ...READ MORE

answered Oct 21, 2020 in Laravel by Niroj
• 82,840 points
6,258 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP