Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rhand's avatar
Level 6

get model attribute for a conditional

When I test the page model for its attributes doing a dd($page) basically grabbing the page model data I get this dd dump:

App\Models\Published\Page {#1482 ▼
  #connection: "mysql_publish"
  #table: "pages"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  +preventsLazyLoading: false
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #escapeWhenCastingToString: false
  #attributes: array:9 [▼
    "id" => 297
    "grid_id" => 40
    "project_id" => 23
    "homepage" => 1
    "name" => "home"
    "slug" => "home"
    "json" => ".....
...

I want to check if homepage is 1 or true basically. How can I grab the value for homepage here?

0 likes
1 reply
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102
if($page->homepage) { //if 1 or true
1 like

Please or to participate in this conversation.