|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Table;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Profile page and profile settings
|
|
|
|
*/
|
|
|
|
class ProfileController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Show the user's profile / dashboard.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function view(User $user)
|
|
|
|
{
|
|
|
|
$data['user'] = $user;
|
|
|
|
$data['tables_count'] = $user->tables()->count();
|
|
|
|
|
|
|
|
$data['tableSort'] = $sort = Table::resolveSortType(\Input::get('tableSort'));
|
|
|
|
$data['sortOptions'] = Table::getSortOptions();
|
|
|
|
|
|
|
|
$data['tables'] = $user->tables()->forList()->tableSort($sort)->paginate(10);
|
|
|
|
|
|
|
|
return view('profile.view', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit own profile (this does not include auth settings etc)
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function editProfile()
|
|
|
|
{
|
|
|
|
return view('profile.edit-profile')->with('user', \user());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store changed profile
|
|
|
|
*/
|
|
|
|
public function storeProfile(Request $request)
|
|
|
|
{
|
|
|
|
$input = $this->validate($request, [
|
|
|
|
'title' => ['required', VALI_LINE],
|
|
|
|
'bio' => ['nullable', VALI_TEXT],
|
|
|
|
'website' => ['nullable', VALI_LINE],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$user = user();
|
|
|
|
$user->fill($input->all());
|
|
|
|
$user->save();
|
|
|
|
|
|
|
|
flash()->success('Settings saved');
|
|
|
|
return back();
|
|
|
|
}
|
|
|
|
}
|