-
-
Save jafar260698/c169893250e85e855772d6838e22c0ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Route; | |
use \App\Http\Controllers\Api\UserController; | |
/* | |
|-------------------------------------------------------------------------- | |
| API Routes | |
|-------------------------------------------------------------------------- | |
| | |
| Here is where you can register API routes for your application. These | |
| routes are loaded by the RouteServiceProvider and all of them will | |
| be assigned to the "api" middleware group. Make something great! | |
| | |
*/ | |
// Route::middleware('auth:sanctum')->get('/user', function (Request $request) { | |
// return $request->user(); | |
// }); | |
//Route::get('/users', [UserController::class, 'index']); | |
Route::apiResources(['users' => UserController::class,]); | |
Route::get('users',[UserController::class], 'index'); | |
This file contains hidden or 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
<?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('users', function (Blueprint $table) { | |
$table->id(); | |
$table->string('login'); | |
$table->string('password'); | |
$table->string('username'); | |
$table->string('phone'); | |
$table->foreignId('user_type_id')->constrained(); | |
$table->timestamp('last_time_verified')->nullable(); | |
$table->timestamps(); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
*/ | |
public function down(): void | |
{ | |
Schema::dropIfExists('users'); | |
} | |
}; |
This file contains hidden or 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
<?php | |
namespace App\Models; | |
use Illuminate\Database\Eloquent\Factories\HasFactory; | |
use Illuminate\Database\Eloquent\Model; | |
class User extends Model | |
{ | |
use HasFactory; | |
} |
This file contains hidden or 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
<?php | |
namespace App\Http\Controllers\Api; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Http\Request; | |
class UserController extends Controller | |
{ | |
/** | |
* Display a listing of the resource. | |
*/ | |
public function index() | |
{ | |
return User::all(); | |
} | |
/** | |
* Store a newly created resource in storage. | |
*/ | |
public function store(Request $request) | |
{ | |
// | |
} | |
/** | |
* Display the specified resource. | |
*/ | |
public function show(string $id) | |
{ | |
return User.find($id); | |
} | |
/** | |
* Update the specified resource in storage. | |
*/ | |
public function update(Request $request, string $id) | |
{ | |
// | |
} | |
/** | |
* Remove the specified resource from storage. | |
*/ | |
public function destroy(string $id) | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment