This commit is contained in:
Your Name 2022-09-14 18:19:38 +08:00
parent 5259ce3889
commit 184b44b1ae
10 changed files with 3176 additions and 1677 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Requests\Api\UserRequest;
use App\Http\Resources\Api\UserResource;
use App\Jobs\Api\SaveLastTokenJob;
use App\Models\Book;
use App\Models\Url;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
class UrlController extends Controller
{
public function index(){
$urls = Url::all();
return $this->success($urls);
}
public function add(Request $req){
$urls = new Url;
//dd($req["name"]);
$urls->host="www";
$urls->url="www.baidu.com";
$urls->save();
return $this->success($urls);
}
}

14
app/Models/Url.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Url extends Model
{
//
protected $fillable = [
'host', 'url'
];
//protected $datas = ['deleted_at'];
}

View File

@ -27,7 +27,14 @@
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
"sort-packages": true,
"platform": {
"ext-pcntl": "7.3",
"ext-posix": "7.3"
},
"allow-plugins": {
"kylekatarnls/update-helper": true
}
},
"extra": {
"laravel": {

4728
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
<?php
return [
'allow-credentials' => env('CORS_ALLOW_CREDENTIAILS', false), // set "Access-Control-Allow-Credentials" 👉 string "false" or "true".
'allow-credentials' => env('CORS_ALLOW_CREDENTIAILS', true), // set "Access-Control-Allow-Credentials" 👉 string "false" or "true".
'allow-headers' => ['*'], // ex: Content-Type, Accept, X-Requested-With
'expose-headers' => ['Authorization'],
'origins' => ['*'], // ex: http://localhost

View File

@ -101,7 +101,7 @@ return [
|
*/
'ttl' => env('JWT_TTL', 60),
'ttl' => env('JWT_TTL', 600000),
/*
|--------------------------------------------------------------------------

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUrlsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('urls', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('urls');
}
}

View File

@ -1,21 +0,0 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

6
public/nginx.htaccess Normal file
View File

@ -0,0 +1,6 @@
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$query_string;
}

View File

@ -14,12 +14,15 @@ use Illuminate\Http\Request;
*/
Route::namespace('Api')->prefix('v1')->middleware('cors')->group(function () {
Route::post('/url/add', 'UrlController@add');
Route::post('/url/all', 'UrlController@index');
Route::post('/url/set', 'UrlController@set');
Route::post('/url/del', 'UrlController@del');
Route::middleware('api.guard')->group(function () {
//用户注册
Route::post('/users', 'UserController@store')->name('users.store');
//用户登录
Route::post('/login', 'UserController@login')->name('users.login');
Route::middleware('api.refresh')->group(function () {
//当前用户信息
Route::get('/users/info', 'UserController@info')->name('users.info');