Skip to content

Commit 04f2e90

Browse files
Add description column to users table
1 parent 56c5064 commit 04f2e90

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ This application includes the following features:
5555
- Full text searching
5656
- Pagination
5757
- Multi delete users
58-
58+
- Inertia.ks progress indicator
59+
- Font Awesome icons
60+
- Application analytics
61+
- User default profile avatar
5962
## Contributing
6063

6164
If you would like to contribute to this project, please follow these steps:

app/Http/Controllers/UserController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public function index(Request $request)
1818
{
1919
return Inertia::render('Users/Index', [
2020
'users' => User::with('role')->when($request->term, function ($query, $term) {
21-
$query->where('name', 'LIKE', '%' . $term . '%');
21+
$query->where('name', 'LIKE', '%' . $term . '%')
22+
->orWhere('email', 'LIKE', '%' . $term . '%');
2223
})->latest()->paginate(5),
2324
]);
2425
}

app/Http/Requests/UserStoreRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function rules(): array
2323
{
2424
return [
2525
'name' => 'required|min:2|max:255',
26+
'description' => 'required|min:2|max:255',
2627
'email' => 'required|email|min:2|max:255|unique:users',
2728
'password' => 'required|min:8|max:255',
2829
'role_id' => 'required',

database/migrations/2014_10_12_000000_create_users_table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ public function up(): void
1616
$table->id();
1717
$table->string('name');
1818
$table->string('email')->unique();
19+
$table->string('description')->default('placeholder');
1920
$table->string('avatar')->default('placeholder');
2021
$table->timestamp('email_verified_at')->nullable();
2122
$table->string('password');
2223
$table->rememberToken();
2324
$table->foreignId('current_team_id')->nullable();
24-
$table->bigInteger('role_id')->unsigned()->index()->nullable();
25+
$table->bigInteger('role_id')->unsigned()->index()->default(2);
2526
// $table->foreign('role_id')->references('id')->on('roles')->cascadeOnDelete();
2627
$table->timestamps();
2728
});

resources/js/Pages/Users/Create.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
<span class="text-red-500">{{ errors.name }}</span>
2525
</div>
2626

27+
<div class="mb-4">
28+
<label class="block mb-2 text-sm font-bold text-gray-700" for="name">
29+
Description <span class="text-red-500">*</span>
30+
</label>
31+
<input v-model="form.description"
32+
class="w-full px-3 py-2 mb-2 leading-tight text-gray-700 border rounded shadow appearance-none focus:outline-none focus:shadow-outline"
33+
id="description" type="text">
34+
<span class="text-red-500">{{ errors.description }}</span>
35+
</div>
36+
2737
<div class="mb-4">
2838
<label class="block mb-2 text-sm font-bold text-gray-700" for="email">
2939
E-mail <span class="text-red-500">*</span>
@@ -77,7 +87,6 @@
7787
</AppLayout>
7888
</template>
7989

80-
8190
<script>
8291
import AppLayout from '@/Layouts/AppLayout.vue';
8392
import Button from '@/Components/Button.vue';
@@ -97,7 +106,8 @@ export default {
97106
email: '',
98107
role_id: 2,
99108
password: '',
100-
avatar: null
109+
avatar: null,
110+
description: ''
101111
})
102112
}
103113
},

resources/js/Pages/Users/Show.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
<hr class="my-4">
1515
<div class="my-2">
1616
<h2 class="text-sm font-bold text-gray-600 uppercase">About</h2>
17-
<p class="mt-2 text-gray-600">{{ user.about }}</p>
17+
<p class="mt-2 text-gray-600">{{ getUser.description != 'placeholder'
18+
? getUser.description
19+
: 'No data available.'
20+
}}
21+
</p>
1822
</div>
1923
</div>
2024
</div>
@@ -27,7 +31,7 @@ import AppLayout from '@/Layouts/AppLayout.vue';
2731
2832
export default {
2933
components: {
30-
AppLayout
34+
AppLayout,
3135
},
3236
props: {
3337
getUser: Object,

0 commit comments

Comments
 (0)