Skip to content

Commit 99b003f

Browse files
committed
complete migrations
1 parent 10f4a76 commit 99b003f

16 files changed

+311
-12
lines changed

app/Http/Controllers/AuthController.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,29 @@
22

33
namespace App\Http\Controllers;
44

5+
use App\Http\Requests\StoreUserRequest;
6+
use App\Traits\HttpResponses;
57
use Illuminate\Http\Request;
68

79
class AuthController extends Controller
810
{
9-
//
11+
use HttpResponses;
12+
13+
public function login()
14+
{
15+
return "login is here";
16+
}
17+
18+
public function register(StoreUserRequest $request)
19+
{
20+
$request->validated($request->all());
21+
22+
}
23+
24+
public function logout()
25+
{
26+
return response()->json([
27+
"message" => "you logged out."
28+
]);
29+
}
1030
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class PostController extends Controller
8+
{
9+
//
10+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class StoreUserRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*/
12+
public function authorize(): bool
13+
{
14+
return false;
15+
}
16+
17+
/**
18+
* Get the validation rules that apply to the request.
19+
*
20+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
21+
*/
22+
public function rules(): array
23+
{
24+
return [
25+
"name" => ["required", "string", "max:255"],
26+
"email" => ["required", "string", "max:255", "unique:users"],
27+
"password" => ["required", "confirmed", Rules / Password::defaults()]
28+
];
29+
}
30+
}

app/Models/Category.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Category extends Model
9+
{
10+
use HasFactory;
11+
}

app/Models/Comment.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Comment extends Model
9+
{
10+
use HasFactory;
11+
}

app/Models/Notification.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Notification extends Model
9+
{
10+
use HasFactory;
11+
}

app/Models/Post.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Post extends Model
9+
{
10+
use HasFactory;
11+
}

app/Models/Tag.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Tag extends Model
9+
{
10+
use HasFactory;
11+
}

database/migrations/2014_10_12_000000_create_users_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function up(): void
1414
Schema::create('users', function (Blueprint $table) {
1515
$table->id();
1616
$table->string('name');
17+
$table->string("username")->unique();
1718
$table->string('email')->unique();
1819
$table->timestamp('email_verified_at')->nullable();
1920
$table->string('password');
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('categories', function (Blueprint $table) {
15+
$table->id();
16+
$table->string("name", 255);
17+
$table->text("description");
18+
$table->timestamps();
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*/
25+
public function down(): void
26+
{
27+
Schema::dropIfExists('categories');
28+
}
29+
};

0 commit comments

Comments
 (0)