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