//関連づけ:associate:外部キーのデータを更新する時:
$project->department()->associate(Department::find($request['department_id']));
//belongsToリレーションを削除する場合はdissociateメソッドを使用します。このメソッドはリレーションの子モデルの外部キーをnullにします。
$user->account()->dissociate();
$user->save();
//contentのserversカラスに attach:中間テープルを作成し、content_id , servers_idを入れる。多対多の時必須。
$content->servers()->attach($serverIds);
//detach:外部キーを消す、外部キーを消さないと、そのままデータを消すとエラーが出る。
$project->servers()->detach();
参考:https://readouble.com/laravel/5.4/ja/mail.html
view変数名を変える方法:with()
public function build()
{
return $this->view('emails.orders.shipped')
->with([
'orderName' => $this->order->name,
'orderPrice' => $this->order->price,
]);
}
//viewで使う時:
<div>
Price: {{ $orderPrice }}
</div>