A
A
Artem2021-05-23 11:38:41
css
Artem, 2021-05-23 11:38:41

Trying to get property 'id' of non-object. How to fix?

When creating a bundle, a ui is created, but does not return an id value.
model test:

class test extends Model
{
    use HasFactory;

    protected $guarded = [];

    public function ui_name() {
        return $this->belongsTo('App\Models\Uis', 'name_id', 'id');
    }

    public function ui_desc() {
        return $this->belongsTo('App\Models\Uis', 'desc_id', 'id');
    }
}

UI Model:
class Uis extends Model
{
    use HasFactory;

    protected $guarded = [];

    public function category() {
        return $this->hasOne('App\Models\Categories\Category', 'ui_id', 'id');
    }

    public function tag() {
        return $this->hasOne('App\Models\Tags\Tag', 'ui_id', 'id');
    }

    public function test_name() {
        return $this->hasOne('App\Models\Tests\test', 'name_id', 'id');
    }

    public function test_desc() {
        return $this->hasOne('App\Models\Tests\test', 'desc_id', 'id');
    }
}

controller:
$test = new test();
        $test->ui_name()->create([
            'text' => "TEXT",
            'desc'=> "TEXT",
            'module_id' =>1, 
            'isHTML' => false
        ]);

tests table:
Schema::create('tests', function (Blueprint $table) {
            $table->id();

            $table->bigInteger('name_id');
            $table->bigInteger('desc_id')->nullable();
            $table->integer('max_ball')->default(20);
            $table->string('password')->nullable();
            $table->string('special_link')->unique()->nullable();
            $table->timestamps();
        });

uitable:
$table->id();
            $table->string('text');
            $table->text('desc');
            $table->bigInteger('module_id')->nullable();
            $table->boolean('isHTML')->default(false);
            $table->timestamps();

Warning:

ErrorException
Trying to get property 'id' of non-object

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Ukolov, 2018-12-20
@alexey-m-ukolov

.owl-item.active:first-of-type

A
Alexander Alekseev, 2018-12-21
@shure348

:first-child will just look for the first element in the block and not the first among .active
if the first element is not .active then the .active:first-child selector will not work
reset can be done via :not(.active) for example

K
Konstantin B., 2021-05-23
@Kostik_1993

$test = new test();
You created an object but didn't save it to the database. And since you didn’t do this, you don’t have the id property either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question