Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion app/Config/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class App extends BaseConfig
* explicitly and never rely on auto-guessing, especially in production
* environments.
*/
public string $baseURL = 'http://text.local/';
public string $baseURL = 'http://towrite.local/';

/**
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function show($id = null)
//
$user = $this->user->find($id);
if($user) {
return view('user/show', compact('post'));
return view('users/show', compact('user'));
}
else {
return redirect()->to('/user');
Expand Down Expand Up @@ -96,7 +96,7 @@ public function edit($id = null)
//
$user = $this->user->find($id);
if($user) {
return view('user/edit', compact('post'));
return view('users/edit', compact('user'));
}
else {
session()->setFlashdata('failed', 'Alert! no post found.');
Expand All @@ -113,7 +113,7 @@ public function update($id = null)
{
//
$inputs = $this->validate([
'title' => 'required|min_length[5]',
'login' => 'required|min_length[5]',
'description' => 'required|min_length[5]',
]);

Expand All @@ -125,7 +125,7 @@ public function update($id = null)

$this->user->save([
'id' => $id,
'title' => $this->request->getVar('title'),
'login' => $this->request->getVar('login'),
'description' => $this->request->getVar('description')
]);
session()->setFlashdata('success', 'Success! post updated.');
Expand Down
54 changes: 54 additions & 0 deletions app/Views/users/edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?= $this->extend('layouts/master');
$this->section('title') ?> Create Post <?= $this->endSection() ?>
<?= $this->section('content') ?>

<div class="container">
<?php $validation = \Config\Services::validation(); ?>

<div class="row py-4">
<div class="col-xl-12 text-end">
<a href="<?= base_url('user') ?>" class="btn btn-primary">Back to Posts</a>
</div>
</div>

<div class="row">
<div class="col-xl-6 m-auto">
<form method="POST" action="<?= base_url('user/'.$user['id']) ?>">
<?= csrf_field() ?>
<input type="hidden" name="_method" value="PUT"/>

<div class="card shadow">
<div class="card-header">
<h5 class="card-title">Update Post</h5>
</div>
<div class="card-body p-4">
<div class="form-group mb-3 has-validation">
<label class="form-label">Post Title</label>
<input type="text" class="form-control <?php if($validation->getError('login')): ?>is-invalid<?php endif ?>" name="login" placeholder="Post Title" value="<?php if($user['login']): echo $user['login']; else: set_value('login'); endif ?>"/>
<?php if ($validation->getError('login')): ?>
<div class="invalid-feedback">
<?= $validation->getError('login') ?>
</div>
<?php endif; ?>
</div>
<div class="form-group">
<label class="form-label">Description</label>
<textarea class="form-control <?php if($validation->getError('description')): ?>is-invalid<?php endif ?>" name="description" placeholder="Description"><?php if($user['description']): echo $user['description']; else: set_value('description'); endif ?></textarea>
<?php if ($validation->getError('description')): ?>
<div class="invalid-feedback">
<?= $validation->getError('description') ?>
</div>
<?php endif; ?>
</div>
</div>

<div class="card-footer">
<button type="submit" class="btn btn-success">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>

<?= $this->endSection() ?>
8 changes: 4 additions & 4 deletions app/Views/users/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<div class="card">
<div class="card-header">
<h5 class="card-title">Posts</h5>
<h5 class="card-title">User</h5>
</div>
<div class="card-body">
<table class="table table-striped">
Expand All @@ -47,9 +47,9 @@
<td><?= $post['login'] ?></td>
<td><?= $post['description'] ?></td>
<td class="d-flex">
<a href="<?= base_url('posts/'.$post['id']) ?>" class="btn btn-sm btn-info mx-1" title="Show"><i class="bi bi-info-square"></i></a>
<a href="<?= base_url('posts/edit/'.$post['id']) ?>" class="btn btn-sm btn-success mx-1" title="Edit"><i class="bi bi-pencil-square"></i></a>
<form class="display-none" method="post" action="<?= base_url('posts/'.$post['id'])?>" id="postDeleteForm<?=$post['id']?>">
<a href="<?= base_url('user/'.$post['id']) ?>" class="btn btn-sm btn-info mx-1" title="Show"><i class="bi bi-info-square"></i></a>
<a href="<?= base_url('user/edit/'.$post['id']) ?>" class="btn btn-sm btn-success mx-1" title="Edit"><i class="bi bi-pencil-square"></i></a>
<form class="display-none" method="post" action="<?= base_url('user/'.$post['id'])?>" id="postDeleteForm<?=$post['id']?>">
<input type="hidden" name="_method" value="DELETE"/>
<a href="jаvascript:void(0)" onclick="deletePost('postDeleteForm<?=$post['id']?>')" class="btn btn-sm btn-danger" title="Delete"><i class="bi bi-trash"></i></a>
</form>
Expand Down
33 changes: 33 additions & 0 deletions app/Views/users/show.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?= $this->extend('layouts/master');
$this->section('title') ?> Show User <?= $this->endSection() ?>
<?= $this->section('content') ?>

<div class="container">
<div class="row py-4">
<div class="col-xl-12 text-end">
<a href="<?= base_url('user') ?>" class="btn btn-primary">Back to Posts</a>
</div>
</div>

<div class="row">
<div class="col-xl-6 m-auto">
<div class="card shadow">
<div class="card-header">
<h5 class="card-title">Show Post</h5>
</div>
<div class="card-body p-4">
<div class="form-group mb-3 has-validation">
<label class="form-label">Post Title</label>
<input type="text" class="form-control" disabled placeholder="Post Title" value="<?php echo trim($user['login']);?>"/>
</div>
<div class="form-group">
<label class="form-label">Description</label>
<textarea class="form-control" disabled name="description" placeholder="Description"><?php echo trim($user['description']);?></textarea>
</div>
</div>
</div>
</div>
</div>
</div>

<?= $this->endSection() ?>
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
},
"scripts": {
"post-update-cmd": [
"CodeIgniter\\ComposerScripts::postUpdate",
"bash -c \"if [ -f admin/setup.sh ]; then bash admin/setup.sh; fi\""
],
"analyze": [
Expand Down
Loading