Skip to content

Commit

Permalink
Created messaging component
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed May 19, 2024
1 parent 2cea6ff commit d69b3ee
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 72 deletions.
19 changes: 18 additions & 1 deletion app/Livewire/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@

namespace App\Livewire;

use App\Models\User;
use Illuminate\View\View;
use Livewire\Component;

class Messages extends Component
{
public $loggedInUser;
public $currentUserRole;
public $search = '';

public function mount(): void
{
$this->loggedInUser = auth()->user();
$this->currentUserRole = $this->loggedInUser->role;
}

public function render(): View
{
return view('messages');
return view('messages',
[
'clients' => User::where('role', 'client')
->where('name', 'like', '%' . $this->search . '%')->orWhere('email', 'like', '%' . $this->search . '%')
->get()
]
);
}
}
25 changes: 24 additions & 1 deletion app/Livewire/OurFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ class OurFeatures extends Component
{
public function render(): View
{
return view('livewire.our-features');
$features = [
[
'icon' => 'fa-check-circle',
'title' => 'Plagiarism Free',
'description' => 'We ensure all our papers are plagiarism free.',
],
[
'icon' => 'fa-user-graduate',
'title' => 'Expert Writers',
'description' => 'Our writers are experts in their respective fields.',
],
[
'icon' => 'fa-clock',
'title' => 'On Time Delivery',
'description' => 'We always deliver our work on time.',
],
[
'icon' => 'fa-money-bill-wave',
'title' => 'Money Back Guarantee',
'description' => 'We offer a money back guarantee if you\'re not satisfied.',
],
];

return view('livewire.our-features', ['features' => $features]);
}
}
7 changes: 6 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public function orders(): HasMany

public function messages(): HasMany
{
return $this->hasMany(Message::class);
return $this->hasMany(Message::class, 'sender_id');
}

public function getLastMessageAttribute(): string
{
return $this->messages()->latest()->first()->message ?? '';
}

public function referrals(): HasMany
Expand Down
7 changes: 1 addition & 6 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();

User::factory()->create([
'name' => 'Test User',
'email' => '[email protected]',
]);
User::factory(100)->create();
}
}
11 changes: 6 additions & 5 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ class="bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-4 rounded-
</div>
</div>

<div class="flex flex-col md:flex-row gap-4 py-2 mt-12">
<div class="w-full md:w-1/2">
</div>
<div class="w-full md:w-1/2">
<div class="flex flex-col gap-4 py-2 mt-14">
<h1 class="text-2xl font-semibold text-center text-gray-800">
Our Service Features
</h1>
<div class="w-full">
<livewire:OurFeatures />
</div>
</div>


</div>
<div class="md:w-1/3 md:absolute p-4 right-0 -top-8 bg-blue-500 md:h-[103vh]">
<div class="md:w-1/3 md:absolute rounded-lg p-4 right-0 -top-8 bg-blue-500 md:h-[103vh]">
<div class="center mt-20">
<div class="center flex-col">
<div class="avatar relative">
Expand Down
49 changes: 12 additions & 37 deletions resources/views/livewire/our-features.blade.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,13 @@
<div class="flex flex-wrap">
<div class="w-full sm:w-1/2 p-2">
<div class="flex flex-col bg-white p-2 rounded-lg">
<i class="fas btn btn-square btn-ghost bg-gray-100 btn-sm fa-check-circle text-blue-500"></i>
<div>
<h2 class="font-bold text-xl">Plagiarism Free</h2>
<p class="text-gray-600">We ensure all our papers are plagiarism free.</p>
</div>
</div>
</div>
<div class="w-full sm:w-1/2 p-2">
<div class="flex flex-col bg-white p-2 rounded-lg">
<i class="fas btn btn-square btn-ghost bg-gray-100 btn-sm fa-user-graduate text-blue-500"></i>
<div>
<h2 class="font-bold text-xl">Expert Writers</h2>
<p class="text-gray-600">Our writers are experts in their respective fields.</p>
</div>
</div>
</div>
<div class="w-full sm:w-1/2 p-2">
<div class="flex flex-col bg-white p-2 rounded-lg">
<i class="fas btn btn-square btn-ghost bg-gray-100 btn-sm fa-clock text-blue-500"></i>
<div>
<h2 class="font-bold text-xl">On Time Delivery</h2>
<p class="text-gray-600">We always deliver our work on time.</p>
</div>
</div>
</div>
<div class="w-full sm:w-1/2 p-2">
<div class="flex flex-col bg-white p-2 rounded-lg">
<i class="fas btn btn-square btn-ghost bg-gray-100 btn-sm fa-money-bill-wave text-blue-500"></i>
<div>
<h2 class="font-bold text-xl">Money Back Guarantee</h2>
<p class="text-gray-600">We offer a money back guarantee if you're not satisfied.</p>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
@foreach($features as $feature)
<div class="flex flex-col bg-white h-44 p-2 rounded-lg">
<div class="flex flex-col bg-white h-44 p-2 rounded-lg">
<i class="fas btn btn-square mb-3 rounded-md btn-ghost bg-gray-100 btn-sm {{ $feature['icon'] }} text-blue-500"></i>
<div>
<h2 class="font-bold text-black/80 text-lg">{{ $feature['title'] }}</h2>
<p class="text-gray-500">{{ $feature['description'] }}</p>
</div>
</div>
</div>
@endforeach
</div>
48 changes: 42 additions & 6 deletions resources/views/messages.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
<div>
<div class="p-2 md:p-0 md:py-4">
<x-slot name="header">
<h2 class="text-gray-800 leading-tight">
<i class="fas text-blue-500 fa-envelope"></i>
{{ __('Messages') }}
</h2>
</x-slot>

<div class="py-8">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
{{ __("You're viewing messages!") }}
<div class="max-w-7xl relative h-full mx-auto">
<div class="flex sm:mx-3 gap-4 lg:mx-4 h-full flex-row">
<div class="h-screen flex gap-2 bg-white w-full rounded-lg">
@if($currentUserRole == 'writer')
<div class="w-1/3 p-3 flex overflow-y-auto flex-col gap-3 rounded-lg">
<!-- Search -->
<div class="flex sticky flex-col rounded-lg">
<div class="flex relative gap-3 bg-gray-100 rounded-lg">
<input type="text" wire:model.live="search" placeholder="Type to search ..."
class="w-full p-2 rounded-lg border border-gray-200 focus:outline-none">
<div
class="absolute text-black/80 right-5 top-[50%] transform translate-x-1/2 -translate-y-1/2">
<i class="fas fa-search"></i>
</div>
</div>
</div>
<div class="h-screen flex overflow-y-auto flex-col gap-3 rounded-lg">

<!-- All users -->
@foreach($clients as $user)
<div class="flex gap-3 cursor-pointer p-2 bg-gray-100 rounded-lg">
<div class="">
<img src="{{ $user->profile_photo }}" alt="{{ $user->name }}"
class="w-12 h-12 rounded-full">
</div>
<div class="w-2/3" wire:click="openChat({{ $user->id }})">
<h1 class="text-gray-800 font-semibold">{{ $user->name }}</h1>

<!-- Last message from user -->
<p class="text-gray-500 text-xs">
{{ $user->lastMessage ? $user->lastMessage->message : 'No message yet' }}
</p>
</div>
</div>
@endforeach
</div>
</div>

@endif
<div class="h-screen bg-gray-500 w-2/3 rounded-lg">

</div>
</div>
</div>
Expand Down
41 changes: 26 additions & 15 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

</head>
<body class="font-sans antialiased">
<nav class="bg-gray-200">
<nav class="bg-gray-100">
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-4">
<div class="flex justify-between items-center">
<a href="#" class="text-2xl font-bold text-black/90">Scholarspace</a>
Expand All @@ -39,25 +39,36 @@ class="bg-green-500 text-black/90 hover:bg-green-600 font-semibold py-2 px-4 rou
<div class="bg-gray-50">
<div class="container mx-auto py-12 px-4 sm:px-6 lg:px-8">
<div class="flex px-1 sm:px-4 lg:px-8 flex-col md:flex-row items-center justify-between">
<div class="text-center relative md:text-left">
<img src="{{ asset('images/svg2.png') }}" alt="Hero" class="w-full opacity-15 max-w-md mx-auto rounded-lg">
<div class="absolute top-0 left-0 w-full h-full flex flex-col justify-center">
<h1 class="text-4xl font-bold text-black/90 mb-4">Welcome to Scholarspace</h1>
<p class="text-lg text-black/50 mb-8">Your trusted platform for assignment help.</p>
<div class="flex justify-center md:justify-start">
<div class="text-center w-2/3 relative md:text-left">
<img src="{{ asset('images/svg2.png') }}" alt="Hero" class="w-64 -top-16 opacity-50 right-0 absolute rounded-lg">
<div class="top-0 left-0 w-full h-full flex flex-col justify-center">
<section class="text-center mb-4 md:text-left">
<header class="mb-4">
<h1 class="text-4xl font-bold text-black/90 leading-snug">
Premium <span class="text-red-500">Essay Writing</span> <br> Services for College Students
</h1>
</header>
<p class="text-lg text-black/50 leading-relaxed">
Struggling with essays? Our <span
class="font-semibold text-blue-500">professional writers</span> are here to help. <br>
We offer <span class="font-semibold text-green-500">top-notch, plagiarism-free essays</span>
tailored to your needs. Choose us for <span class="font-semibold text-yellow-500">quality and punctuality</span>.
Experience a stress-free academic life with Scholarspace.
</p>
</section>
<div class="flex justify-center mt-4 md:justify-start">
<a href="{{ route('login') }}"
class="bg-blue-500 text-white/90 hover:bg-blue-600 font-semibold py-2 px-4 rounded-md mr-4">
Login
</a>
<a href="{{ route('register') }}"
class="bg-green-500 text-black/90 hover:bg-green-600 font-semibold py-2 px-4 rounded-md">
Register
class="bg-blue-500 text-white/90 hover:bg-blue-600 font-semibold py-2 pl-2 rounded-lg mr-4">
Solve my paper
<span class="mx-2 rounded-md bg-white bg-opacity-20 btn-ghost btn btn-square btn-sm">
<i class="fas fa-arrow-right"></i>
</span>
</a>
</div>
</div>
</div>
<div class="mt-8 md:mt-0">
<livewire:PriceCalculator />
<livewire:PriceCalculator/>
</div>
</div>
</div>
Expand All @@ -70,7 +81,7 @@ class="bg-green-500 text-black/90 hover:bg-green-600 font-semibold py-2 px-4 rou
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
@php
$colors = ['text-blue-500', 'text-green-500', 'text-yellow-500', 'text-red-500'];
$colors = ['text-blue-500', 'text-green-500', 'text-yellow-500', 'text-red-500'];
@endphp
@foreach($process_steps as $item)
<div class="bg-white rounded-lg shadow-md shadow-gray-200 p-6">
Expand Down

0 comments on commit d69b3ee

Please sign in to comment.