DEV Community

Thomas Costigan
Thomas Costigan

Posted on

VS Code

can anyone tell me where the protected guarded id goes and how to format it into the code. The code isn't accepting it

<?php

namespace App\Models;

use App\Traits\Sortable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Vacancy extends Model
protected $guarded = ['id'];

{
/** @use HasFactory<\Database\Factories\VacancyFactory> */
use HasFactory, Sortable;

public function applications():  HasMany {
    return $this->HasMany(Application::class);
  }

}   


//add applications has many relationship

public function casts(): array
{
    return [
        'application_open' => 'date',
        'application_close' => 'date',
    ];
}

public function scopeSearch(Builder $query, $search) {

    return $query->where('title', 'like', "%{$search}%");
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)