Skip to content

Commit

Permalink
style: migration update public files
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Apr 28, 2021
1 parent fe957b5 commit 0d221ad
Showing 1 changed file with 11 additions and 13 deletions.
@@ -1,22 +1,21 @@
<?php

use Soosyze\Config;
use Queryflatfile\Request;
use Queryflatfile\Schema;
use Soosyze\Config;

return [
'up' => function ( Schema $sch, Request $req )
{
'up' => function (Schema $sch, Request $req) {
$search = 'app/files';
$replace = 'public/files';

if( $sch->hasTable('entity_article') ) {
if ($sch->hasTable('entity_article')) {
$articles = $req->from('entity_article')->fetchAll();
foreach( $articles as $article ) {
foreach ($articles as $article) {
$req
->update('entity_article', [
'body' => str_replace($search, $replace, $article[ 'body' ]),
"summary" => str_replace($search, $replace, $article[ 'summary' ]),
'summary' => str_replace($search, $replace, $article[ 'summary' ]),
'image' => str_replace($search, $replace, $article[ 'image' ])
])
->where('article_id', $article[ 'article_id' ])
Expand All @@ -25,7 +24,7 @@
}

$pages = $req->from('entity_page')->fetchAll();
foreach( $pages as $page ) {
foreach ($pages as $page) {
$req
->update('entity_page', [
'body' => str_replace($search, $replace, $page[ 'body' ])
Expand All @@ -35,8 +34,8 @@
}

$users = $req->from('user')->fetchAll();
foreach( $users as $user ) {
if( empty($user[ 'picture' ]) ) {
foreach ($users as $user) {
if (empty($user[ 'picture' ])) {
continue;
}
$req
Expand All @@ -47,9 +46,9 @@
->execute();
}

if( $sch->hasTable('block') ) {
if ($sch->hasTable('block')) {
$blocks = $req->from('block')->fetchAll();
foreach( $blocks as $block ) {
foreach ($blocks as $block) {
$req
->update('block', [
'content' => str_replace($search, $replace, $block[ 'content' ])
Expand All @@ -59,8 +58,7 @@
}
}
},
'up_config' => function ( Config $config )
{
'up_config' => function (Config $config) {
$search = 'app/files';
$replace = 'public/files';

Expand Down

0 comments on commit 0d221ad

Please sign in to comment.