Bläddra i källkod

fixed loading of templates

Josh 4 år sedan
förälder
incheckning
696c99b387

+ 1 - 1
app/Models/Note.php

@@ -30,6 +30,6 @@ class Note extends Model
 
     public function sections()
     {
-        return $this->hasMany(Section::class, 'note_id', 'id');
+        return $this->hasMany(Section::class, 'note_id', 'id')->orderBy('position_index', 'asc');
     }
 }

+ 1 - 0
config/view.php

@@ -14,6 +14,7 @@ return [
     */
 
     'paths' => [
+        storage_path(),
         resource_path('views'),
     ],
 

+ 0 - 12
resources/views/sections/name/summary.blade.php

@@ -1,12 +0,0 @@
-<?php 
-    $content_data = json_decode($section->content_data, true);
-
-    $firstName = isset($content_data['firstName'])?$content_data['firstName']:'';
-    $lastName = isset($content_data['lastName'])?$content_data['lastName']:'';
-
-?>
-
-<div>
-    <strong>First name: </strong> {{$firstName}} <br/>
-    <strong>Last name: </strong> {{$lastName}}
-</div>

+ 0 - 49
resources/views/sections/test2/form.blade.php

@@ -1,49 +0,0 @@
-<?php
-$contentData = [
-    'nickname'=>'',
-    'favoriteColor'=>''
-]; 
-if($section){
-    $contentData = json_decode($section->content_data, true);
-}
-
-$nickname = isset($contentData['nickname'])?$contentData['nickname']:'nickname is not set';
-$favoriteColor = isset($contentData['favoriteColor'])?$contentData['favoriteColor']:'favorite color is not set';
-?>
-
-
-
-<div>
-
-    <div class="card">
-        <div class="card-header">
-            <?php if(!$section):?>
-            <div class="alert alert-info">Create section</div>
-            <?php else: ?>
-            <div class="alert alert-info">Update section</div>
-            <?php endif; ?>
-        </div>
-        <div class="card-body">
-            <form method="POST" action="/process_form_submit" up-history="false">
-                <?php if($section): ?>
-                    <input type="hidden" name="section_uid" value="<?= $section->uid?>">
-                <?php else: ?>
-                    <input type="hidden" name="note_uid" value="<?= $note->uid?>">
-                    <input type="hidden" name="section_template_uid" value="<?= $sectionTemplate->uid ?>">
-                <?php endif; ?>
-                <div class="form-group">
-                    <label for="">Nickname</label>
-                    <input type="text" class="form-control" name="nickname" value="<?= $nickname ?>" placeholder="nickname">
-                </div>
-                <div class="form-group">
-                    <label for="">Favorite color</label>
-                    <input type="text" class="form-control" name="favoriteColor" value="<?= $favoriteColor ?>" placeholder="Favorite color">
-                </div>
-                <div class="form-group">
-                    <button class="btn btn-primary">Submit</button>
-                </div>
-            </form>
-        </div>
-
-    </div>
-</div>

+ 0 - 4
resources/views/sections/test2/summary.blade.php

@@ -1,4 +0,0 @@
-<?php $content_data = json_decode($section->content_data, true) ?>
-<div  style="background-color:<?= isset($content_data['favoriteColor'])?$content_data['favoriteColor']:'not set'; ?>; ">
-    <h1>Nickname: <?= isset($content_data['nickname'])? $content_data['nickname'] : 'not set'; ?></h1>
-</div>

+ 0 - 33
resources/views/sections/weight/summary.blade.php

@@ -1,33 +0,0 @@
-<?php
-$content_data = json_decode($section->content_data, true);
-
-$currentWeight = [];
-
-if (isset($content_data['currentWeight'])) {
-    $currentWeight  = $content_data['currentWeight'];
-}
-
-
-$weight = isset($currentWeight['weight']) ? $currentWeight['weight'] : '';
-$effectiveDate = isset($currentWeight['effectiveDate']) ? $currentWeight['effectiveDate'] : '';
-
-$weightLog = [];
-if(isset($content_data['weightLog'])){
-    $weightLog = $content_data['weightLog'];
-}
-
-?>
-
-<div>
-    <strong>Current weight: </strong> {{$weight}} <br/>
-    <strong>Effective date: </strong> {{$effectiveDate}}<br/>
-    <strong>Weight log</strong>
-    <table>
-    @foreach($weightLog as $weight)
-        <tr>
-            <td>{{$weight['effectiveDate']}}</td>
-            <td>{{$weight['weight']}}</td>
-        </tr>
-    @endforeach
-    </table>
-</div>

+ 4 - 4
resources/views/sections/name/form.blade.php → storage/sections/name/form.blade.php

@@ -3,8 +3,8 @@
 
 $contentData = json_decode($section->content_data, true);
 
-$firstName = isset($content_data['firstName']) ? $content_data['firstName'] : '';
-$lastName = isset($content_data['lastName']) ? $content_data['lastName'] : '';
+$firstName = isset($contentData['firstName']) ? $contentData['firstName'] : '';
+$lastName = isset($contentData['lastName']) ? $contentData['lastName'] : '';
 
 ?>
 
@@ -17,12 +17,12 @@ $lastName = isset($content_data['lastName']) ? $content_data['lastName'] : '';
                 
                 <div class="form-group">
                     <label for="">First Name</label>
-                    <input type="text" class="form-control" name="firstName" value="{{$firstName}}" placeholder="first name">
+                    <input type="text" class="form-control" name="firstName" value="<?= $firstName ?>" placeholder="first name">
                 </div>
 
                 <div class="form-group">
                     <label for="">Last Name</label>
-                    <input type="text" class="form-control" name="lastName" value="{{$lastName}}" placeholder="last name">
+                    <input type="text" class="form-control" name="lastName" value="<?= $lastName ?>" placeholder="last name">
                 </div>
                 <div class="form-group">
                     <button class="btn btn-primary">Submit</button>

+ 2 - 2
storage/sections/name/summary.php

@@ -7,6 +7,6 @@
 ?>
 
 <div>
-    <strong>First name: </strong> {{$firstName}} <br/>
-    <strong>Last name: </strong> {{$lastName}}
+    <strong>First name: </strong> <?= $firstName ?> <br/>
+    <strong>Last name: </strong> <?= $lastName ?>
 </div>

+ 2 - 2
resources/views/sections/weight/form.blade.php → storage/sections/weight/form.blade.php

@@ -23,12 +23,12 @@ $effectiveDate = isset($currentWeight['effectiveDate']) ? $currentWeight['effect
                 
                 <div class="form-group">
                     <label for="">Weight</label>
-                    <input type="text" class="form-control" name="weight" value="{{$weight}}" placeholder="weight">
+                    <input type="text" class="form-control" name="weight" value="<?= $weight ?>" placeholder="weight">
                 </div>
 
                 <div class="form-group">
                     <label for="">Effective Date</label>
-                    <input type="date" class="form-control" name="effectiveDate" value="{{$effectiveDate}}" placeholder="effective date">
+                    <input type="date" class="form-control" name="effectiveDate" value="<?= $effectiveDate ?>" placeholder="effective date">
                 </div>
                 <div class="form-group">
                     <button class="btn btn-primary">Submit</button>

+ 6 - 6
storage/sections/weight/summary.php

@@ -19,15 +19,15 @@ if(isset($content_data['weightLog'])){
 ?>
 
 <div>
-    <strong>Current weight: </strong> {{$weight}} <br/>
-    <strong>Effective date: </strong> {{$effectiveDate}}<br/>
+    <strong>Current weight: </strong>  <?= $weight ?> <br/>
+    <strong>Effective date: </strong> <?= $effectiveDate ?><br/>
     <strong>Weight log</strong>
     <table>
-    @foreach($weightLog as $weight)
+    <?php foreach($weightLog as $weight): ?>
         <tr>
-            <td>{{$weight['effectiveDate']}}</td>
-            <td>{{$weight['weight']}}</td>
+            <td><?= $weight['effectiveDate'] ?></td>
+            <td><?= $weight['weight'] ?></td>
         </tr>
-    @endforeach
+    <?php endforeach; ?>
     </table>
 </div>