action = $action; $this->request = $request; $this->model = $offer_us_vehicle; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(OfferUsVehicle $offer_us_vehicle, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $offer_us_vehicle = $offer_us_vehicle->create($attributes); return $offer_us_vehicle; } public function update(OfferUsVehicle $offer_us_vehicle, array $request) { $attributes = $request; $offer_us_vehicle->update($attributes); return $offer_us_vehicle; } public function destroy(OfferUsVehicle $offer_us_vehicle, array $request) { $offer_us_vehicle->delete(); return $offer_us_vehicle; } public function copy(OfferUsVehicle $offer_us_vehicle, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $offer_us_vehicle = $offer_us_vehicle->replicate(); $offer_us_vehicle->created_at = Carbon::now(); $offer_us_vehicle->save(); return $offer_us_vehicle; } for ($i = 1; $i <= $count; $i++) { $new = $offer_us_vehicle->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $offer_us_vehicle; } }