You need to call get() on promo. At the moment $promo is an instance of the Query Builder - the query itself hasn't run yet. As such:
$promo = PromoDetailModel::where('promo_code', $promo_code)->get();
will return a collection of Eloquent models.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I want to pass value to the tables -
PromoController.php
public function pdetail_listPromo(Request $request){
$promo_code = $request->promo_code;
$promo = PromoDetailModel::where('promo_code', $promo_code);
dd($promo);
die();
return view('pages.promo.pdetail_list')->with('list', $promo);
}
This is the result:
Builder {#219 ▼
#query: Builder {#218 ▼
+connection: MySqlConnection {#214 ▶}
+grammar: MySqlGrammar {#215 ▼
#operators: array:1 [▶]
#selectComponents: array:11 [▼
0 => "aggregate"
1 => "columns"
2 => "from"
3 => "joins"
4 => "wheres"
5 => "groups"
6 => "havings"
7 => "orders"
8 => "limit"
9 => "offset"
10 => "lock"
]
#tablePrefix: ""
}
+processor: MySqlProcessor {#216}
+bindings: array:7 [▶]
+aggregate: null
+columns: null
+distinct: false
+from: "tb_m_promo_detail"
+joins: null
+wheres: array:1 [▼
0 => array:5 [▼
"type" => "Basic"
"column" => "promo_code"
"operator" => "="
"value" => "LISTRIKCERIA"
"boolean" => "and"
]
]
+groups: null
+havings: null
+orders: null
+limit: null
+offset: null
+unions: null
+unionLimit: null
+unionOffset: null
+unionOrders: null
+lock: null
+operators: array:29 [▶]
+useWritePdo: false
}
#model: PromoDetailModel {#213 ▼
#table: "tb_m_promo_detail"
#connection: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: false
+wasRecentlyCreated: false
#attributes: []
#original: []
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
}
#eagerLoad: []
#localMacros: []
#onDelete: null
#passthru: array:12 [▼
0 => "insert"
1 => "insertGetId"
2 => "getBindings"
3 => "toSql"
4 => "exists"
5 => "doesntExist"
6 => "count"
7 => "min"
8 => "max"
9 => "avg"
10 => "sum"
11 => "getConnection"
]
#scopes: []
#removedScopes: []
}
I wonder why the data does not appears in array since after checking the tables -
TAGIHANCERIA 10 001 10 NULL 30000 active 2018-09-06 06:52:22 1 Ubah Ubah Salin Salin Hapus Hapus TAGIHANCERIA 10 002 10 NULL 30000 active 2018-09-06 06:52:22 1 Ubah Ubah Salin Salin Hapus Hapus TAGIHANCERIA 10 003 10 NULL 30000 active 2018-09-06 06:52:22 1
Please or to participate in this conversation.