我正在创建用户个人资料,并且试图在选择div中显示TITRE_ANNONCE
,但出现错误:
试图获取非对象的属性
这是我的表格:
<div class="col-lg-4">
<select class="contact_input" name="NOM_ARTICLE">
@foreach($user as $annonce)
<option> {{$annonce->TITRE_ANNONCE}}</option>
@endforeach
</select>
</div>
使用我的控制器:
public function voirprofile($id) {
$user = DB::table('users')->
join('article', 'article.id', '=', 'users.id')->
join('annonce', 'annonce.ID_ARTICLE', '=', 'article.ID_ARTICLE')->
where('users.id', $id)->
get();
return view('voirprofile') - > with('user', $user);
}
$ user包含他发布的所有“ nononce”的用户信息。 这就是$ user返回的内容:
[
{
"id":1,
"name":"Othmane Messaoud",
"email":"othmane.messaoud@gmail.com",
"password":"$2y$10$at2J0teHoorwI7Y396Ckh.l1EvRojWJzomx4Ccqsf9LYA0j0oRxl.",
"ville":"Rabat",
"region":"Irfan",
"ID_Ville":1,
"tele_user":642213124,
"type_user":0,
"adresse":"Maroc, Rabat Al Irfan ENSIAS",
"presentation":"je m'appelle othmane",
"remember_token":"RPoRKcupcaBujbYoUj0e7QlmYaq0ybrhiKg3bHDwtQNK02DxLa7DPAi1QwsX",
"created_at":"2019-03-30 13:56:06",
"updated_at":"2019-03-30 13:56:06",
"ID_ARTICLE":1,
"TYPE_ARTICLE":"1",
"NOM_ARTICLE":"Le maitre des illusions",
"DESCRIPTION_ARTICLE":"ici la description de mon livre 'Le maitre des illusions' !!",
"ID_ANNONCE":1,
"TITRE_ANNONCE":"Annonce 1",
"DATE_DEPOT":null,
"TYPE_ANNONCE":"1",
"PRIX":200,
"ETAT_ANNONCE":1,
"MOTIF_REFUS":null
},
{
"id":1,
"name":"Othmane Messaoud",
"email":"othmane.messaoud@gmail.com",
"password":"$2y$10$at2J0teHoorwI7Y396Ckh.l1EvRojWJzomx4Ccqsf9LYA0j0oRxl.",
"ville":"Rabat",
"region":"Irfan",
"ID_Ville":1,
"tele_user":642213124,
"type_user":0,
"adresse":"Maroc, Rabat Al Irfan ENSIAS",
"presentation":"je m'appelle othmane",
"remember_token":"RPoRKcupcaBujbYoUj0e7QlmYaq0ybrhiKg3bHDwtQNK02DxLa7DPAi1QwsX",
"created_at":"2019-04-09 15:39:30",
"updated_at":"2019-04-09 15:39:30",
"ID_ARTICLE":84,
"TYPE_ARTICLE":"livre",
"NOM_ARTICLE":"zednumber5",
"DESCRIPTION_ARTICLE":"fsd",
"ID_ANNONCE":26,
"TITRE_ANNONCE":"voilae",
"DATE_DEPOT":"2019-04-09 17:40:43",
"TYPE_ANNONCE":"1",
"PRIX":100,
"ETAT_ANNONCE":1,
"MOTIF_REFUS":null
},
{
"id":1,
"name":"Othmane Messaoud",
"email":"othmane.messaoud@gmail.com",
"password":"$2y$10$at2J0teHoorwI7Y396Ckh.l1EvRojWJzomx4Ccqsf9LYA0j0oRxl.",
"ville":"Rabat",
"region":"Irfan",
"ID_Ville":1,
"tele_user":642213124,
"type_user":0,
"adresse":"Maroc, Rabat Al Irfan ENSIAS",
"presentation":"je m'appelle othmane",
"remember_token":"RPoRKcupcaBujbYoUj0e7QlmYaq0ybrhiKg3bHDwtQNK02DxLa7DPAi1QwsX",
"created_at":"2019-04-09 14:57:05",
"updated_at":"2019-04-09 14:57:05",
"ID_ARTICLE":83,
"TYPE_ARTICLE":"cahier",
"NOM_ARTICLE":"besttestthatworks",
"DESCRIPTION_ARTICLE":"sdfkljsdfkjl",
"ID_ANNONCE":25,
"TITRE_ANNONCE":"voila",
"DATE_DEPOT":"2019-04-09 16:57:20",
"TYPE_ANNONCE":"1",
"PRIX":100,
"ETAT_ANNONCE":1,
"MOTIF_REFUS":null
}
]
这是我数据库中的正确数据。
答案 0 :(得分:0)
尝试
step=0
a_list=["A","B","C"]
for s in a_list:
cursor = tweepy.Cursor(api1.user_timeline, id = s, tweet_mode='extended').items(3189)
for tweet in cursor:
tw_text.append(tweet.full_text)
created_at.append(tweet.created_at)
rtws.append(tweet.retweet_count)
favs.append(tweet.favorite_count)
for h in tweet.entities['hashtags']:
hashlist.append(h['text'])
for u in tweet.entities['urls']:
linklist.append(u['expanded_url'])
try:
medialist.append(media['media_url'] for media in tweet.entities['media'])
except:
pass
step+=1
print('step {} completed'.format(step))
#preparing all the data for .executemany()
g = [(s,tw,crea,rt,fv,ha,li,me) for s in ['GameOfThrones'] for tw in tw_text for crea in created_at for rt in rtws for fv in favs for ha in hashlist for li in linklist for me in medialist]
cur.executemany("INSERT INTO series_data VALUES (?,?,?,?,?,?,?,?)", (g))
con.commit()
print('db updated')
答案 1 :(得分:0)
使用可选助手
<div class="col-lg-4">
<select class="contact_input" name="NOM_ARTICLE" >
@foreach($user as $annonce)
<option> {{optional($annonce)->TITRE_ANNONCE}}</option>
@endforeach
</select>
</div>
更改
{{$ annonce-> TITRE_ANNONCE}}
致
{{optional($ annonce)-> TITRE_ANNONCE}}