mirror of
https://github.com/v2board/v2board.git
synced 2025-06-12 12:37:54 +08:00
update
This commit is contained in:
28
app/Http/Controllers/Admin/NoticeController.php
Normal file
28
app/Http/Controllers/Admin/NoticeController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\Admin\NoticeSave;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Notice;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class NoticeController extends Controller
|
||||
{
|
||||
public function index (Request $request) {
|
||||
return response([
|
||||
'data' => Notice::get()
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (NoticeSave $request) {
|
||||
$data = $request->only([
|
||||
'title',
|
||||
'content'
|
||||
]);
|
||||
return response([
|
||||
'data' => Notice::create($data)
|
||||
]);
|
||||
}
|
||||
}
|
17
app/Http/Controllers/NoticeController.php
Normal file
17
app/Http/Controllers/NoticeController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Notice;
|
||||
use App\Utils\Helper;
|
||||
|
||||
class NoticeController extends Controller
|
||||
{
|
||||
public function index (Request $request) {
|
||||
return response([
|
||||
'data' => Notice::orderBy('created_at', 'DESC')->first()
|
||||
]);
|
||||
}
|
||||
}
|
29
app/Http/Requests/Admin/NoticeSave.php
Normal file
29
app/Http/Requests/Admin/NoticeSave.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NoticeSave extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'content' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'title.required' => '标题不能为空',
|
||||
'content.required' => '内容不能为空'
|
||||
];
|
||||
}
|
||||
}
|
12
app/Models/Notice.php
Normal file
12
app/Models/Notice.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Notice extends Model
|
||||
{
|
||||
protected $table = 'v2_notice';
|
||||
protected $dateFormat = 'U';
|
||||
protected $guarded = ['id'];
|
||||
}
|
Reference in New Issue
Block a user