1. Go to this page and download the library: Download shengfai/laravel-admin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Controllers\Admin;
use App\Models\School;
use App\Services\SchoolService;
use Illuminate\Http\Request;
use Shengfai\LaravelAdmin\Controllers\Controller;
/**
* 学校控制台
* Class SchoolController
*
* @author ShengFai <[email protected]>
* @version 2020年4月16日
*/
class SchoolController extends Controller
{
/**
* The title of the page.
*
* @var string $title
*/
protected $title = '学校管理';
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$queryBuilder = School::sorted();
return $this->list($queryBuilder);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$types = School::types();
$this->assign('types', $types);
return $this->form();
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$newSchoolData = collect($request->all());
$activity = (new SchoolService())->store($newSchoolData);
return $this->success('数据添加成功', '');
}
/**
* Display the specified resource.
*
* @param \App\Models\School $school
* @return \Illuminate\Http\Response
*/
public function show(School $school)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\School $school
* @return \Illuminate\Http\Response
*/
public function edit(School $school)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\School $school
* @return \Illuminate\Http\Response
*/
public function update(Request $request, School $school)
{
// 更新指定字段
if ($request->isMethod('Patch')) {
tap($school)->update([
$request->field => $request->value
]);
return $this->success('数据更新成功', '');
}
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\School $school
* @return \Illuminate\Http\Response
*/
public function destroy(School $school)
{
//
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.