-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
182 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
database/migrations/2024_10_25_132943_create__friendships_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('friendships', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('user_id')->constrained('users')->onDelete('cascade'); | ||
$table->foreignId('friend_id')->constrained('users')->onDelete('cascade'); | ||
$table->timestamps(); | ||
$table->enum('status', ['pending', 'accepted', 'blocked'])->default('pending'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('friendships'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<x-app-layout> | ||
<h1 class="text-2xl font-bold mb-4">Add a Friend</h1> | ||
|
||
@if(session('success')) | ||
<div class="bg-green-500 text-white p-4 rounded mb-4"> | ||
{{ session('success') }} | ||
</div> | ||
@elseif(session('error')) | ||
<div class="bg-red-500 text-white p-4 rounded mb-4"> | ||
{{ session('error') }} | ||
</div> | ||
@endif | ||
|
||
<form action="{{ route('friends.store') }}" method="POST" class="space-y-4"> | ||
@csrf | ||
<div> | ||
<label for="name" class="block text-sm font-medium text-gray-700">Name</label> | ||
<input type="text" name="name" id="name" required | ||
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500"> | ||
</div> | ||
|
||
<div> | ||
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600"> | ||
Add Friend | ||
</button> | ||
</div> | ||
</form> | ||
</x-app-layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters