Laravel_api/app/Http/Controllers/Api/UrlController.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2022-09-14 18:19:38 +08:00
<?php
2022-09-25 21:39:39 +08:00
2022-09-14 18:19:38 +08:00
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;
2022-09-25 21:39:39 +08:00
use App\Models\Log;
2022-09-14 18:19:38 +08:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
2022-09-25 21:39:39 +08:00
use Illuminate\Support\Facades\DB;
2022-09-14 18:19:38 +08:00
class UrlController extends Controller
{
2022-09-25 21:39:39 +08:00
public function index()
{
2022-09-14 18:19:38 +08:00
$urls = Url::all();
return $this->success($urls);
}
2022-09-25 21:39:39 +08:00
public function add(Request $req)
{
$hosts = $req->hosts;
foreach ($hosts as $v) {
$urls = new Url;
$urls->host = $v;
$urls->save();
}
return $this->success("");
}
public function del(Request $req)
{
$id = $req->id;
Url::where('id', $id)->delete();
return $this->success("");
}
public function set(Request $req)
{
$host = $req->host;
$url = $req->url;
$log = new Log;
$log->host = $host;
$log->url = $url;
$log->save();
Url::where('host', $host)->update(['url' => $url]);
return $this->success("");
} public function text()
{
//$users = DB::select('select * from `users` where `name` = giaogiao limit 1');
return $this->success("");
2022-09-14 18:19:38 +08:00
}
2022-09-25 21:39:39 +08:00
}