I have this code which store offer and maxoffer but I can't use it into my Mail function:
public function store(Requests\OfferRequest $request)
{
$offer = new Offer($request->all());
Auth::user()->offer()->save($offer);
$maxoffer = Maxoffer::where('article_id', $request->input('article_id'))
->where('start', Carbon::createFromFormat('m/d/Y h:i a', $request->input('start')))
->first();
//dd($maxoffer);
if($maxoffer == null)
{
Auth::user()->maxoffer()->create($request->all());
}
else
{
if($maxoffer->price < $request->input('price'))
{
$key = '';
$newOffer = Maxoffer::where('id', $maxoffer->id)
->update(['price'=>$request->input('price'),'user_id'=>Auth::user()->id, 'key'=>$key, 'provera'=>$request->input('provera')]);
}
}
Alert::success('Keep looking for best rates. Good luck...', 'Thanks for bidding!')->persistent("Close");
$user = Auth::user();
Mail::send('emails.newoffer', compact('user', 'maxoffer'), function ($m) use ($user) {
$m->from('info@sss.com', $maxoffer->article()->hname);
$m->to($user->email, $user->name)->subject('Someone have the bigger offer than you');
});
return Redirect::back();
}
so In Maxoffer controller I have:
public function user(){
return $this->belongsTo('App\User');
}
public function article(){
return $this->belongsTo('App\Article');
}
but in Mail function I cant use it. WHY?
Why $maxoffer->article()->hname
inside Mail::
is a problem...
laravel error:
i get errors: ErrorException in 22b7e7ff4b942f1d8fa25f9b1c9a1748 line 6: Undefined property: Illuminate\Database\Eloquent\Relations\BelongsTo::$hname (View: /var/www/html/resources/views/emails/newoffer.blade.php)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire