Laravel - 基于关系的事件

时间:2018-04-18 23:04:00

标签: php laravel laravel-5 laravel-5.5 laravel-5.6

我有以下型号。

  1. Shipment
  2. ShipmentPiece
  3. Shipment可以有多个ShipmentPiece个实例。 ShipmentPiece属于Shipment

    当我将新creating附加到saving时,是否存在模型事件(与ShipmentPieceShipment相同)?

    例如,当我这样做时:

    $shipment->shipmentPieces()->save($shipmentPiece);
    

    $shipment->shipmentPieces()->saveMany([$piece1, $piece2]);
    

    我想在Shipment类中的boot类中运行一些逻辑。

0 个答案:

没有答案