|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class ProfileController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Show the application dashboard.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function view(User $user)
|
|
|
|
{
|
|
|
|
$tables = $user->tables()
|
|
|
|
->with('revision:id,row_count')
|
|
|
|
->orderByDesc('updated_at')
|
|
|
|
->paginate(10);
|
|
|
|
|
|
|
|
return view('profile.view')->with(compact('tables', 'user'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit own profile (this does not include auth settings etc)
|
|
|
|
*
|
|
|
|
* @param User $user
|
|
|
|
* @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, [
|
|
|
|
'bio' => ['nullable', VALI_TEXT],
|
|
|
|
'title' => ['required', VALI_LINE],
|
|
|
|
'website' => ['required', VALI_LINE],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$user = user();
|
|
|
|
$user->fill($input->all());
|
|
|
|
$user->save();
|
|
|
|
|
|
|
|
flash()->success('Settings saved');
|
|
|
|
return back();
|
|
|
|
}
|
|
|
|
}
|