What can I name a model in Laravel 5?

I'm trying to get Laravel 5 and ask a question, which is probably very easy to solve, but I'm afraid.

I have a controller called TestController and it is located in \ app \ Http \ Controllers

This is the controller:

<?php 
namespace App\Http\Controllers;

class TestController extends Controller {

    public function test()
    {

    $diamonds = diamonds::find(1);
    var_dump($diamonds);
    }



}

Then I have a model that I created that resides in / app:

<?php

namespace App;


class diamonds extends Model {


}

Set aside all other errors that I am sure there are, my problem is that laravel is causing the error:

FatalErrorException in line TestController.php 10: class 'App \ Http \ Controllers \ diamonds' not found

So, how can I make the controller understand that I am pointing to a model, not a controller?

Thanks in advance...

+4
source share
4 answers

.

.

use App\Customer;

class DashboardController extends Controller {
    public function index() {
        $customers = Customer::all();
        return view('my/customer/template')->with('customers', $customers);
    }
}

App\diamonds::find(1); use App\diamonds; , .

, UpperCamelCase. . dd() (dump die) var_dump, .

+5

...

use App\Diamonds;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

(, Diamonds.php)

+2
  //Your model file
  <?php
    namespace App\Models;


    class diamonds extends Model {


    }

  // And in your controller
  <?php 
    namespace App\Http\Controllers;

    use App\Models\

    class TestController extends Controller {

    public function test()
    {

      $diamonds = diamonds::find(1);
      var_dump($diamonds);
    }

 }
+2

, , , :

use Illuminate\Database\Eloquent\Model;
0

All Articles