blue-twilight/database/data_migrations/DataMigrationV2_0_0_alpha_1.php

27 lines
537 B
PHP

<?php
use App\Album;
use App\DataMigration;
class DataMigrationV2_0_0_alpha_1 extends DataMigration
{
public function run($currentVersion)
{
$this->storeAlbumUrlPaths();
}
/**
* Ensures all albums have a full URL path stored.
* @return void
*/
private function storeAlbumUrlPaths()
{
$albumsWithNoPath = Album::where('url_path', null)->get();
/** @var Album $album */
foreach ($albumsWithNoPath as $album)
{
$album->touch();
}
}
}