0

so, my model looks like this

<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class SkillsEmployee extends Model
{
    protected $table = 'skills_employee';

    protected $fillable = [
        'id', 'HTML', 'JavaScript','React', 'PHP', 'C#', 'C++', 'JQuery', 'Phyton', 'Symphony',
    ];


    protected $hidden = [];
}

and my controller is

<?php

namespace App\Http\Controllers;

use app\Models\SkillsEmployee;

class SkillsController extends Controller
{

    public function index()
    {
        $Skills = SkillsEmployee::all();
        dd($Skills);

    }
}
GluePear
  • 7,244
  • 20
  • 67
  • 120

2 Answers2

2

even thou the folder name is app, the PHP namespace is by default App, if you use an IDE that can help you a lot in your are new in the field.

So in the Controller.

namespace App\Http\Controllers;

use App\Models\SkillsEmployee; // app was lower case

class SkillsController extends Controller
mrhn
  • 17,961
  • 4
  • 27
  • 46
1

Take a look at this for laravel naming conventions : https://github.com/alexeymezenin/laravel-best-practices#follow-laravel-naming-conventions

and here you can learn php coding style https://www.php-fig.org/psr/psr-2/ with this you can lean any new php framework more easily.

Controller : singular : ExampleController

Route : plural : articles/1

Model : singular : User

As code mentioned by @Martin Henriksen that's how you should implement it.

Happy Coding. :)

Vipertecpro
  • 3,056
  • 2
  • 24
  • 43