Skip to content
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
/**
Expand Down
34 changes: 34 additions & 0 deletions app/Http/Controllers/MessageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Controllers;

use App\Models\Message;
use Illuminate\Http\Request;

class MessageController extends Controller
{
public function index()
{
$messages = Message::paginate(15);
$messages->sortByDesc('id');
return view('messages.index', compact('messages'));
}

public function show(Message $message)
{
return view('messages.show', compact('message'));
}

public function store(Request $request)
{
$message= Message::create($request->validated());

return redirect()->route('messages.index');
}

public function destroy(Message $message)
{
$message->delete();
return redirect(route('messages.index'));
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Hash;
use App\Http\Requests\ProfileUpdateRequest;
use Illuminate\Support\Facades\Hash;

class ProfileController extends Controller
{
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Requests/ProfileUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http\Requests;

use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;

class ProfileUpdateRequest extends FormRequest
{
Expand All @@ -28,4 +28,4 @@ protected function prepareForValidation()
$this->request->remove('password');
}
}
}
}
12 changes: 12 additions & 0 deletions app/Models/Message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
use HasFactory;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fillable

protected $fillable = ['name', 'email', 'content'];
}
36 changes: 36 additions & 0 deletions database/migrations/2022_08_12_151510_create_messages_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('messages', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
$table->string('phone');
$table->text('content');
$table->timestamps();
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('messages');
}
};
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 81 additions & 38 deletions resources/views/layouts/navigation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@
<div class="navbar navbar-light">
<div class="container-xl">
<ul class="navbar-nav">

<li class="nav-item @if(request()->routeIs('home')) active @endif">
<a class="nav-link" href="{{ route('home') }}" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><!-- Download SVG icon from http://tabler-icons.io/i/home -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><polyline points="5 12 3 12 12 3 21 12 19 12" /><path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" /><path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" /></svg>

<li class="nav-item @if (request()->routeIs('home')) active @endif">
<a class="nav-link" href="{{ route('home') }}">
<span class="nav-link-icon d-md-none d-lg-inline-block">
<!-- Download SVG icon from http://tabler-icons.io/i/home -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<polyline points="5 12 3 12 12 3 21 12 19 12" />
<path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
<path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>
</span>
<span class="nav-link-title">
{{ __('Dashboard') }}
</span>
</a>
</li>

<li class="nav-item @if(request()->routeIs('users.index')) active @endif">
<a class="nav-link" href="{{ route('users.index') }}" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><!-- Download SVG icon from http://tabler-icons.io/i/file-text -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-users" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<li class="nav-item @if (request()->routeIs('users.index')) active @endif">
<a class="nav-link" href="{{ route('users.index') }}">
<span class="nav-link-icon d-md-none d-lg-inline-block">
<!-- Download SVG icon from http://tabler-icons.io/i/file-text -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-users"
width="24" height="24" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"></path>
Expand All @@ -32,60 +43,92 @@
</a>
</li>

<li class="nav-item @if(request()->routeIs('about')) active @endif">
<a class="nav-link" href="{{ route('about') }}" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><!-- Download SVG icon from http://tabler-icons.io/i/file-text -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-info-circle" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="12" cy="12" r="9"></circle>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
<polyline points="11 12 12 12 12 16 13 16"></polyline>
</svg>
<li class="nav-item @if (request()->routeIs('about')) active @endif">
<a class="nav-link" href="{{ route('about') }}">
<span class="nav-link-icon d-md-none d-lg-inline-block">
<!-- Download SVG icon from http://tabler-icons.io/i/file-text -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-info-circle"
width="24" height="24" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="12" cy="12" r="9"></circle>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
<polyline points="11 12 12 12 12 16 13 16"></polyline>
</svg>
</span>
<span class="nav-link-title">
{{ __('About') }}
</span>
</a>
</li>

<li class="nav-item @if (request()->routeIs('messages.index')) active @endif">
<a class="nav-link" href="{{ route('messages.index') }}">
<span class="nav-link-icon d-md-none d-lg-inline-block">
<!-- Download SVG icon from http://tabler-icons.io/i/file-text -->
<svg xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-message-circle" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M3 20l1.3 -3.9a9 8 0 1 1 3.4 2.9l-4.7 1"></path>
<line x1="12" y1="12" x2="12" y2="12.01"></line>
<line x1="8" y1="12" x2="8" y2="12.01"></line>
<line x1="16" y1="12" x2="16" y2="12.01"></line>
</svg>
</span>
<span class="nav-link-title">
{{ __('Messages') }}
</span>
</a>
</li>

<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#navbar-extra" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-expanded="false" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><!-- Download SVG icon from http://tabler-icons.io/i/star -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-list-details" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<a class="nav-link dropdown-toggle" href="#navbar-extra" data-bs-toggle="dropdown"
data-bs-auto-close="outside" role="button" aria-expanded="false">
<span class="nav-link-icon d-md-none d-lg-inline-block">
<!-- Download SVG icon from http://tabler-icons.io/i/star -->
<svg xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-list-details" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M13 5h8"></path>
<path d="M13 9h5"></path>
<path d="M13 15h8"></path>
<path d="M13 19h5"></path>
<rect x="3" y="4" width="6" height="6" rx="1"></rect>
<rect x="3" y="14" width="6" height="6" rx="1"></rect>
<rect x="3" y="4" width="6" height="6"
rx="1"></rect>
<rect x="3" y="14" width="6" height="6"
rx="1"></rect>
</svg>
</span>
<span class="nav-link-title">
Submenus
Submenus
</span>
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" >
<a class="dropdown-item" href="#">
Submenu Item #1
</a>
<div class="dropend">
<a class="dropdown-item dropdown-toggle" href="#" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-expanded="false">
<a class="dropdown-item dropdown-toggle" href="#" data-bs-toggle="dropdown"
data-bs-auto-close="outside" role="button" aria-expanded="false">
Submenu Item #2
</a>
<div class="dropdown-menu">
<a href="#" class="dropdown-item">
Subsubmenu Item #1
</a>
<a href="#" class="dropdown-item">
Subsubmenu Item #2
</a>
<a href="#" class="dropdown-item">
Subsubmenu Item #3
</a>
<a href="#" class="dropdown-item">
Subsubmenu Item #1
</a>
<a href="#" class="dropdown-item">
Subsubmenu Item #2
</a>
<a href="#" class="dropdown-item">
Subsubmenu Item #3
</a>
</div>
</div>
<a class="dropdown-item" href="#" >
</div>
<a class="dropdown-item" href="#">
Submenu Item #3
</a>
</div>
Expand All @@ -95,4 +138,4 @@
</div>
</div>
</div>
</div>
</div>
53 changes: 53 additions & 0 deletions resources/views/messages/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@extends('layouts.app')

@section('content')
<div class="container-xl">
<!-- Page title -->
<div class="page-header d-print-none">
<h2 class="page-title">
{{ __('Messages') }}
</h2>
</div>
</div>
<div class="page-body">
<div class="container-xl">
<table class="table table-vcenter">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>phone</th>
<th>received at</th>
<th class="w-1"></th>
</tr>
</thead>
<tbody>
@foreach ($messages as $message)
<tr>
<td>{{ $message->id }}</td>
<td><a href="{{ route('messages.show', $message->id) }}">{{ $message->name }}</a></td>
<td>{{ $message->phone }}</td>
<td>{{ $message->created_at }}</td>
<td class="text-center row">
<div>
<form action="{{ route('messages.destroy', $message) }}" method="POST">
@csrf @method('DELETE')
<button type="submit" value="delete" class="btn btn-sm btn-danger">Delete</button>
</form>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
{{ $messages->links() }}
</div>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format the code properly & add pagination links

</div>
@endsection

<style>
.pagination {
justify-content: center;
}
</style>

Loading