Doubt Laravel Trait

Asked

Viewed 27 times

1

Good staff ,

I have the following Trait in the Laravel

<?php

namespace App\Traits;

trait Imageable {

    public function getUrlImageAttribute(): string {
        ....
    }

}

I use the same in the following Model

namespace App\Models;

use App\Traits\Imageable;
use Spatie\Activitylog\Traits\LogsActivity;

class Page extends Model
{
    use Imageable,
        LogsActivity;

    public $timestamps = false;
    protected $fillable = ['title', 'description', 'slug', 'image'];
    protected $appends = ['url_image'];
    protected static $logFillable = true;
    protected static $logName = 'Page Logs';
    
//RESTO DOS METODOS
}

My question is why if I put one dd() in Trait and make save() of something in the Model it stops at the dd() and if you look for an id on Model with the ::findOrFail no longer stops?

  • Place the source of the complete trait and model here and if possible on Brazilian Standard.

  • Ola is here https://paste.laravel.io/e1d53be6-9c0e-4d3e-8c6a-64314d89e187 https://paste.laravel.io/5cc3f346-f862-4a4c-97bb-4b0184fa8850

  • Probably you are, after Model::save, redirecting to a route that looks for something in the bank, as it is giving a dd in the access getUrlImageAttribute() , dd is not stopping in Model::save but after it, ie when searching the records in the database

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.