Laravel not creating objects of specific Model
Ad
I have a Model Comment.php and the table comments on the DB.
I have some seeders that are able to insert data in that table and a bunch of other models and controllers already working.
The problem is that whenever im trying to create a new Comment it comes empty. For example:
{
$comment = new Comment([
'description' => $request->input('description'),
'status' => 'active',
'profile_id' => $request->input('profile_id')
]);
return $comment;
}
returns
[]
I made sure the Model and the Controller both exists. I can actually index all the comments. I am also using the right Model:
use App\Comment;
Any idea where should I check or why does Laravel/Eloquent is not recognizing the model when trying to create a new object?
Edit:
This is my Model:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
public $fillable = ['*'];
public function profile(){
$this->belongsTo(Profile::class);
}
public function project(){
$this->belongsTo(Project::class);
}
public function scopeOfProject($query,$projectId){
return $query->where('project_id',$projectId);
}
Ad
Answer
Ad
public $fillable = ['*'];
Was the problem.
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad