Exemple #1
0
            # Save the changes
            $animal->save();
        }
        echo "Update complete; check the database to see if your update worked...";
    } else {
        echo "Animals not found, can't update.";
    }
});
Route::get('/modelCat', function () {
    $animal = new \CareCats\Animal();
    $animal->name = 'Ace';
    $animal->sex = 'male';
    $animal->sub_species = 'jaguar';
    $animal->enclosure = 'J';
    $animal->save();
    dump($animal->toArray());
    $procedure = new \CareCats\Procedure();
    $procedure->title = "Hates Derek";
    $procedure->symptoms = "grumpy around derek";
    $procedure->comments = "nothing to do!";
    $procedure->animal()->associate($animal);
    # <--- Associate the author with this procedure
    $procedure->save();
    dump($procedure->toArray());
});
Route::get('/modelQuery', function () {
    $procedure = \CareCats\Procedure::first();
    dump($procedure->toArray());
    # Get the animal from this procedure using the "animal" dynamic property
    # "animal" corresponds to the the relationship method defined in the procedure model
    $animal = $procedure->animal;