Merge branch 'contrev' into 'master'

Controller and route restructure.

See merge request 076/community/076Server!3
このコミットが含まれているのは:
テクニカル諏訪子 2018-02-07 16:34:07 +09:00
コミット 4cd34218dd
12個のファイルの変更148行の追加408行の削除

ファイルの表示

@ -1,32 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

ファイルの表示

@ -1,39 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}

ファイルの表示

@ -1,71 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}

ファイルの表示

@ -1,39 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

ファイルの表示

@ -1,43 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class CategoryController extends Controller {
public function getCategories() { // /api/rpc/store/category/getcategories
return DB::table('str_category')
->select('*')
->get();
}
public function getCategory($id) { // /api/rpc/store/category/getcategory/1
return DB::table('str_category')
->select('*')
->where('id', $id)
->get();
}
public function getCategoryParent($id) { // /api/rpc/store/category/getcategoryparent/1
return DB::table('str_category')
->select('parent_id')
->where('id', $id)
->get();
}
public function getCategoryMinScreenshots($id) { // /api/rpc/store/category/getcategoryminscrot/1
return DB::table('str_category')
->select('min_screenshots')
->where('id', $id)
->get();
}
public function getCategoryName($id) { // /api/rpc/store/category/getcategoryname/id
return DB::table('str_category')
->select('name')
->where('id', $id)
->get();
}
}

ファイルの表示

@ -1,36 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class ExampleController extends Controller {
public function __contruct() {
// Init SQL.
}
public function getUsers() {
// Select all users from the database, and return the results.
}
public function getUser($id) {
// Select a specific user from the database, and return the result.
}
public function addUser(Request $request) {
// Insert a specific user into the database, and return the result.
}
public function editUser(Request $request) {
// Update a specific user in the database, and return the result.
}
public function deleteUser(Request $request) {
// Delete a specific user from the database, and return the result.
}
public function browse(Request $request) {
// If needed, set a fuckton of stuff, and return the desired results.
}
}

ファイルの表示

@ -1,66 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class OwnerController extends Controller {
public function countOwnersOfFile($file_id) { // /api/rpc/user/owner/countownersoffile/id
return DB::table('str_owners')
->where('file_id', $file_id)
->count();
}
public function getOwnersOfFile($file_id) { // /api/rpc/user/owner/getownersoffile/id
return DB::table('str_owners')
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
->where('file_id', $file_id)
->get(array(
"user_id",
"title",
"version",
"views",
"downloads",
"submit_date",
"last_date",
"username",
"avatar",
"perm_id",
"gender",
"display_name",
"name_colour",
));
}
public function countFilesOfOwner($user_id) { // /api/rpc/user/owner/countfilesofowner/id
return DB::table('str_owners')
->where('user_id', $user_id)
->count();
}
public function getFilesOfOwner($user_id) { // /api/rpc/user/owner/getfilesofowner/id
return DB::table('str_owners')
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
->where('user_id', $user_id)
->get(array(
"user_id",
"title",
"version",
"views",
"downloads",
"submit_date",
"last_date",
"username",
"avatar",
"perm_id",
"gender",
"display_name",
"name_colour",
));
}
}

ファイルの表示

@ -6,35 +6,72 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class FileController extends Controller {
public function getAllFiles() { // /api/rpc/store/file/getallfiles
class StoreController extends Controller {
// Category
public function getCategories() { // /api/rpc/store/category/getcategories
return DB::table('str_category')
->select('*')
->get();
}
public function getCategory($id) { // /api/rpc/store/category/getcategory/1
return DB::table('str_category')
->select('*')
->where('id', $id)
->get();
}
public function getCategoryParent($id) { // /api/rpc/store/category/getcategoryparent/1
return DB::table('str_category')
->select('parent_id')
->where('id', $id)
->get();
}
public function getCategoryMinScreenshots($id) { // /api/rpc/store/category/getcategoryminscrot/1
return DB::table('str_category')
->select('min_screenshots')
->where('id', $id)
->get();
}
public function getCategoryName($id) { // /api/rpc/store/category/getcategoryname/id
return DB::table('str_category')
->select('name')
->where('id', $id)
->get();
}
// Entries
public function getAllEntries() { // /api/rpc/store/entry/getallentries
return DB::table('str_file')
->select('*')
->get();
}
public function getAllApprovedFiles() { // /api/rpc/store/file/getallapprovedfiles
public function getAllApprovedEntries() { // /api/rpc/store/entry/getallapprovedentries
return DB::table('str_file')
->select('*')
->where('isApproved', 1)
->get();
}
public function getAllBrokenFiles() { // /api/rpc/store/file/getallbrokenfiles
public function getAllBrokenEntries() { // /api/rpc/store/entry/getallbrokenentries
return DB::table('str_file')
->select('*')
->where('isBroken', 1)
->get();
}
public function getAllPendingFiles() { // /api/rpc/store/file/getallpendingfiles
public function getAllPendingEntries() { // /api/rpc/store/entry/getallpendingentries
return DB::table('str_file')
->select('*')
->where('isApproved', 0)
->get();
}
public function getNewFiles() { // /api/rpc/store/file/getnewfiles
public function getNewEntries() { // /api/rpc/store/entry/getnewentries
return DB::table('str_file')
->select(
'id',
@ -48,7 +85,7 @@ class FileController extends Controller {
->get();
}
public function getHotFiles() { // /api/rpc/store/file/gethotfiles
public function getHotEntries() { // /api/rpc/store/entry/gethotentries
return DB::table('str_file')
->select(
'id',
@ -62,7 +99,7 @@ class FileController extends Controller {
->get();
}
public function getFilesPageAll($cat, $from, $to) { // /api/rpc/store/file/getfilespageall/cat/from/to
public function getEntriesPageAll($cat, $from, $to) { // /api/rpc/store/entry/getentriespageall/cat/from/to
return DB::table('str_file')
->select(
'id',
@ -80,7 +117,7 @@ class FileController extends Controller {
->get();
}
public function getFilesPageApproved($cat, $from, $to) { // /api/rpc/store/file/getfilespageapproved/cat/from/to
public function getEntriesPageApproved($cat, $from, $to) { // /api/rpc/store/entry/getentriespageapproved/cat/from/to
return DB::table('str_file')
->select(
'id',
@ -99,7 +136,7 @@ class FileController extends Controller {
->get();
}
public function getFilesPagePopularView($cat, $from, $to) { // /api/rpc/store/file/getfilespagepopularview/cat/from/to
public function getEntriesPagePopularView($cat, $from, $to) { // /api/rpc/store/entry/getentriespagepopularview/cat/from/to
return DB::table('str_file')
->select(
'id',
@ -118,7 +155,7 @@ class FileController extends Controller {
->get();
}
public function getFilesPagePopularDownload($cat, $from, $to) { // /api/rpc/store/file/getfilespagepopulardownload/cat/from/to
public function getEntriesPagePopularDownload($cat, $from, $to) { // /api/rpc/store/entry/getentriespagepopulardownload/cat/from/to
return DB::table('str_file')
->select(
'id',
@ -137,7 +174,7 @@ class FileController extends Controller {
->get();
}
public function getFile($id) { // /api/rpc/store/file/getfile/id
public function getEntry($id) { // /api/rpc/store/entry/getentry/id
return DB::table('str_owners')
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
@ -163,38 +200,38 @@ class FileController extends Controller {
));
}
public function getFileName($id) { // /api/rpc/store/file/getfilename/id
public function getEntryName($id) { // /api/rpc/store/entry/getfilename/id
return DB::table('str_file')
->select('title')
->where('id', $id)
->get();
}
public function getFilesInCategory($cat_id) { // /api/rpc/store/file/getfilesincategory/cat_id
public function getEntriesInCategory($cat_id) { // /api/rpc/store/entry/getentriesincategory/cat_id
return DB::table('str_file')
->select('*')
->where('cat_id', $cat_id)
->get();
}
public function countFilesInCategory($cat_id) { // /api/rpc/store/file/countfilesincategory/cat_id
public function countEntriesInCategory($cat_id) { // /api/rpc/store/entry/countentriesincategory/cat_id
return DB::table('str_file')
->where('cat_id', $cat_id)
->where('isApproved', 1)
->count();
}
public function countFilesInCategoryFull($cat_id) { // /api/rpc/store/file/countfilesincategoryfull/cat_id
public function countEntriesInCategoryFull($cat_id) { // /api/rpc/store/entry/countentriesincategoryfull/cat_id
return DB::table('str_file')
->where('cat_id', $cat_id)
->count();
}
public function insertEntry(Request $request) { // /api/rpc/store/file/insert
public function insertEntry(Request $request) { // /api/rpc/store/entry/insert
return;
}
public function updateEntry(Request $request) { // /api/rpc/store/file/update
public function updateEntry(Request $request) { // /api/rpc/store/entry/update
return DB::table('str_file')
->where('id', $request->id)
->update([
@ -208,13 +245,13 @@ class FileController extends Controller {
]);
}
public function restoreEntry(Request $request) { // /api/rpc/store/file/restore
public function restoreEntry(Request $request) { // /api/rpc/store/entry/restore
return DB::table('str_file')
->where('id', $request->id)
->update(['isApproved', 1]);
}
public function removeEntry(Request $request) { // /api/rpc/store/file/remove
public function removeEntry(Request $request) { // /api/rpc/store/entry/remove
return DB::table('str_file')
->where('id', $request->id)
->update(['isApproved', 0]);

ファイルの表示

@ -12,6 +12,7 @@ use Tymon\JWTAuth\Facades\JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
class UserController extends Controller {
// User
public function getUsers() { // /api/rpc/user/user/getusers
return DB::table('for_users')
->select('*')
@ -113,10 +114,9 @@ class UserController extends Controller {
//dd($cookieP);
//dd($request);
//dd($cookie->name));
//return response('')
//->cookie('username', $cookieU)
//->cookie('password', $cookieP);
}
//return response('')
//->cookie('username', $cookieU)
//->cookie('password', $cookieP);
}
return "bad";
@ -136,4 +136,62 @@ class UserController extends Controller {
// public function passwordReset() {}
// public function confirmReset() {}
// Owner
public function countOwnersOfEntry($file_id) { // /api/rpc/user/owner/countownersofentry/id
return DB::table('str_owners')
->where('file_id', $file_id)
->count();
}
public function getOwnersOfEntry($file_id) { // /api/rpc/user/owner/getownersofentry/id
return DB::table('str_owners')
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
->where('file_id', $file_id)
->get(array(
"user_id",
"title",
"version",
"views",
"downloads",
"submit_date",
"last_date",
"username",
"avatar",
"perm_id",
"gender",
"display_name",
"name_colour",
));
}
public function countEntriesOfOwner($user_id) { // /api/rpc/user/owner/countentriesofowner/id
return DB::table('str_owners')
->where('user_id', $user_id)
->count();
}
public function getEntriesOfOwner($user_id) { // /api/rpc/user/owner/getentriesofowner/id
return DB::table('str_owners')
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
->where('user_id', $user_id)
->get(array(
"user_id",
"title",
"version",
"views",
"downloads",
"submit_date",
"last_date",
"username",
"avatar",
"perm_id",
"gender",
"display_name",
"name_colour",
));
}
}

ファイルの表示

@ -1,29 +0,0 @@
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}

ファイルの表示

@ -12,31 +12,31 @@
*/
// Category
Route::get('/api/rpc/store/category/getcategories', 'CategoryController@getCategories');
Route::get('/api/rpc/store/category/getcategory/{id}', 'CategoryController@getCategory');
Route::get('/api/rpc/store/category/getcategoryparent/{id}', 'CategoryController@getCategoryParent');
Route::get('/api/rpc/store/category/getcategoryminscrot/{id}', 'CategoryController@getCategoryMinScreenshots');
Route::get('/api/rpc/store/category/getcategoryname/{id}', 'CategoryController@getCategoryName');
Route::get('/api/rpc/store/category/getcategories', 'StoreController@getCategories');
Route::get('/api/rpc/store/category/getcategory/{id}', 'StoreController@getCategory');
Route::get('/api/rpc/store/category/getcategoryparent/{id}', 'StoreController@getCategoryParent');
Route::get('/api/rpc/store/category/getcategoryminscrot/{id}', 'StoreController@getCategoryMinScreenshots');
Route::get('/api/rpc/store/category/getcategoryname/{id}', 'StoreController@getCategoryName');
// File
// Entry
// Just to test middleware.
Route::get('/api/rpc/store/file/getallfiles', 'FileController@getAllFiles');
Route::get('/api/rpc/store/entry/getallentries', 'StoreController@getAllEntries');
//->middleware('auth');
Route::get('/api/rpc/store/file/getallapprovedfiles', 'FileController@getAllApprovedFiles');
Route::get('/api/rpc/store/file/getallbrokenfiles', 'FileController@getAllBrokenFiles');
Route::get('/api/rpc/store/file/getallpendingfiles', 'FileController@getAllPendingFiles');
Route::get('/api/rpc/store/file/getnewfiles', 'FileController@getNewFiles');
Route::get('/api/rpc/store/file/gethotfiles', 'FileController@getHotFiles');
Route::get('/api/rpc/store/file/getfilespageall/{cat}/{from}/{to}', 'FileController@getFilesPageAll');
Route::get('/api/rpc/store/file/getfilespageapproved/{cat}/{from}/{to}', 'FileController@getFilesPageApproved');
Route::get('/api/rpc/store/file/getfilespagepopularview/{cat}/{from}/{to}', 'FileController@getFilesPagePopularView');
Route::get('/api/rpc/store/file/getfilespagepopulardownload/{cat}/{from}/{to}', 'FileController@getFilesPagePopularDownload');
Route::get('/api/rpc/store/file/getfile/{id}', 'FileController@getFile');
Route::get('/api/rpc/store/file/getfilename/{id}', 'FileController@getFileName');
Route::get('/api/rpc/store/file/getfilesincategory/{cat_id}', 'FileController@getFilesInCategory');
Route::get('/api/rpc/store/file/countfilesincategory/{cat_id}', 'FileController@countFilesInCategory');
Route::get('/api/rpc/store/file/countfilesincategoryfull/{cat_id}', 'FileController@countFilesInCategoryFull');
Route::post('/api/rpc/store/file/insert', 'FileController@insertEntry');
Route::post('/api/rpc/store/file/update', 'FileController@updateEntry');
Route::post('/api/rpc/store/file/restore', 'FileController@restoreEntry');
Route::post('/api/rpc/store/file/remove', 'FileController@removeEntry');
Route::get('/api/rpc/store/entry/getallapprovedentries', 'StoreController@getAllApprovedEntries');
Route::get('/api/rpc/store/entry/getallbrokenentries', 'StoreController@getAllBrokenEntries');
Route::get('/api/rpc/store/entry/getallpendingentries', 'StoreController@getAllPendingEntries');
Route::get('/api/rpc/store/entry/getnewentries', 'StoreController@getNewEntries');
Route::get('/api/rpc/store/entry/gethotentries', 'StoreController@getHotEntries');
Route::get('/api/rpc/store/entry/getentriespageall/{cat}/{from}/{to}', 'StoreController@getEntriesPageAll');
Route::get('/api/rpc/store/entry/getentriespageapproved/{cat}/{from}/{to}', 'StoreController@getEntriesPageApproved');
Route::get('/api/rpc/store/entry/getentriespagepopularview/{cat}/{from}/{to}', 'StoreController@getEntriesPagePopularView');
Route::get('/api/rpc/store/entry/getentriespagepopulardownload/{cat}/{from}/{to}', 'StoreController@getEntriesPagePopularDownload');
Route::get('/api/rpc/store/entry/getentry/{id}', 'StoreController@getEntry');
Route::get('/api/rpc/store/entry/getentryname/{id}', 'StoreController@getEntryName');
Route::get('/api/rpc/store/entry/getentriesincategory/{cat_id}', 'StoreController@getEntriesInCategory');
Route::get('/api/rpc/store/entry/countentriesincategory/{cat_id}', 'StoreController@countEntriesInCategory');
Route::get('/api/rpc/store/entry/countentriesincategoryfull/{cat_id}', 'StoreController@countEntriesInCategoryFull');
Route::post('/api/rpc/store/entry/insert', 'StoreController@insertEntry');
Route::post('/api/rpc/store/entry/update', 'StoreController@updateEntry');
Route::post('/api/rpc/store/entry/restore', 'StoreController@restoreEntry');
Route::post('/api/rpc/store/entry/remove', 'StoreController@removeEntry');

ファイルの表示

@ -20,10 +20,10 @@ Route::group(['middleware' => 'jwt'], function () {
});
// Owner
Route::get('/api/rpc/user/owner/countownersoffile/{id}', 'OwnerController@countOwnersOfFile');
Route::get('/api/rpc/user/owner/getownersoffile/{id}', 'OwnerController@getOwnersOfFile');
Route::get('/api/rpc/user/owner/countfilesofowner/{id}', 'OwnerController@countFilesOfOwner');
Route::get('/api/rpc/user/owner/getfilesofowner/{id}', 'OwnerController@getFilesOfOwner');
Route::get('/api/rpc/user/owner/countownersofentry/{id}', 'UserController@countOwnersOfEntry');
Route::get('/api/rpc/user/owner/getownersofentry/{id}', 'UserController@getOwnersOfEntry');
Route::get('/api/rpc/user/owner/countentriesofowner/{id}', 'UserController@countEntriesOfOwner');
Route::get('/api/rpc/user/owner/getentriesofowner/{id}', 'UserController@getEntriesOfOwner');
// User
Route::get('/api/rpc/user/user/getusers', 'UserController@getUsers');