本文整理汇总了PHP中Authorization::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorization::user方法的具体用法?PHP Authorization::user怎么用?PHP Authorization::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authorization
的用法示例。
在下文中一共展示了Authorization::user方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display the specified resource.
*
* @param int $hash
* @return Response
*/
public function index($hash)
{
if ($hash) {
$wishes = $this->service->getWishesForUser($hash);
} else {
$wishes = $this->service->getWishesForUser(\Authorization::user()->hash);
}
return $this->returnWishlist($wishes);
}
示例2: makeAuth
public static function makeAuth($args) {
$md5pass = md5($args[1].Config::$Security['passwordsalt']);
$table = Config::$DBConf['prefix'].Authorization::$table;
$row = DB::getRow("Select * From $table Where `login`='$args[0]' and `password`='$md5pass'");
if($row != NULL && $row['status'] == '0' ){
self::$user = $row;
DB::exec( "UPDATE $table SET `status` = 1 WHERE `login` = '".$args[0]."'" );
setcookie("user_name",$row['name'], time()+60*60*24*365);
setcookie("user_id",$row['id'], time()+60*60*24*365);
return $row['category'];
}else return NULL;
}
示例3: store
public function store(Request $request)
{
$file = $request->file('upload');
if (!$request->hasFile('upload') || !$request->has('type')) {
throw new BadRequestHttpException();
}
$unique = \Input::get('unique');
if (!$unique) {
$unique = true;
}
$uploadType = ['type' => \Input::get('type'), 'unique' => $unique];
$user = \Authorization::user();
$model = $this->service->createUpload($user, $file, \Authorization::user(), $uploadType);
$model = $this->returnUploadModel($model);
return $model;
}
示例4: store
public function store($hash)
{
$in = \Input::all();
$files = array();
$fileCount = intval($in['fileCount']);
if ($fileCount > 0) {
for ($i = 0; $i < $fileCount; $i++) {
array_push($files, \Input::file('uploads' . $i));
}
}
$in['project_hash'] = $hash;
$new = $this->service->createActivity(\Authorization::user(), $in, 1, $files, 1);
if (!is_array($new)) {
return $this->returnActivityModel($new);
} else {
return $this->returnActivityModelWithParent($new);
}
}
示例5: iAmImplicit
/**
* Implicit version of iAm(), attempts to do Authorization::user when it's not given directly.
* Currently needs to force Dingo/Api to invoke authentication.
*
* In an exported package, this mechanism would probably be delegated to a configuration file.
*
* @see https://github.com/dingo/api/issues/92
*
* since dingo api isn't compatible with laravel 5 we'll have to do some API authenticaiton of our own but right
* now we'll just stub this
*/
protected function iAmImplicit()
{
// break if the user is already authenticated
if ($this->authenticated && $this->authenticatedUser) {
return;
}
// silence exceptions. If shield authentication fails, simply do nothing.
// for instance, a test may fail because Route::current() is null (since it's being called from a test).
try {
/** @var Shield $shield */
//$shield = \App::make('Dingo\Api\Authorization\Shield');
//$user = $shield->authenticate(\Request::instance(), \Route::current());
$user = Auth::user();
if ($user) {
Auth::setUser($user);
}
} catch (\Exception $e) {
}
if (!$this->authenticatedUser) {
$this->iAm(Auth::user());
}
return;
}
示例6: deleteProject
public function deleteProject($hash)
{
return $this->projectRepository->deleteProject(\Authorization::user(), $hash);
}
示例7: dismiss
public function dismiss($notification)
{
$this->notificationService->dismiss($notification, \Authorization::user());
return ['message' => 'Notification dismissed'];
}
示例8: function
Route::post('projects/', ['uses' => 'ProjectController@store']);
Route::get('projects', ['uses' => 'ProjectController@index']);
Route::get('projects/{resource}', ['uses' => 'ProjectController@show']);
Route::put('projects/{resource}', ['uses' => 'ProjectController@update']);
Route::delete('projects/{resource}', ['uses' => 'ProjectController@destroy']);
Route::get('projects/{resource}/activity', ['uses' => 'ActivityController@index']);
Route::get('projects/{resource}/activity/{Hash}', ['uses' => 'ActivityController@show']);
Route::post('projects/{resource}/activity', ['uses' => 'ActivityController@store']);
Route::get('projects/users/{hash}', ['uses' => 'ProjectController@showUserProjects']);
Route::post('wishes/{resource}', ['uses' => 'WishlistController@store']);
Route::get('wishes/{resource}', ['uses' => 'WishlistController@index']);
Route::delete('wishes/{resource}', ['uses' => 'WishlistController@destroy']);
Route::post('uploads', ['uses' => 'UploadController@store']);
Route::get('uploads', ['uses' => 'UploadController@index']);
Route::resource('uploads', 'UploadController');
Route::resource('projects', 'ProjectController');
Route::resource('users', 'UserController');
Route::resource('notifications', 'NotificationController');
Route::resource('wishes', 'WishlistController');
});
Route::post('signup/users', ['uses' => 'UserController@store']);
route::post('signupOrSignin', ['uses' => 'UserController@signupOrSignin']);
Route::post('oauth/access_token', function () {
\Authorization::attempt(['email' => Input::get('username'), 'password' => Input::get('password')]);
$user = \Authorization::user();
$transformer = \App::make(\HOFB\Users\UserTransformer::class);
$response = Authorizer::issueAccessToken();
$transformed = $transformer->transform($user);
$response['user'] = $transformed;
return Response::json($response);
});
示例9: returnProjectModels
public function returnProjectModels(Collection $collection)
{
$user = \Authorization::user();
$wishlist = WishModel::where('user_id', '=', $user->id)->get();
if ($user->userable_type == BuyerModel::class) {
$collection->filter(function ($item) use($wishlist) {
$wishlist->contains('project_id', $item->id) ? $item->wishlisted = true : ($item->wishlisted = false);
return $item;
});
}
return $this->withCollection($collection, new ProjectTransformer());
}
示例10: search
public function search(Request $request)
{
$input = Input::all();
$model = \Authorization::user();
switch ($model->userable_type) {
case AdministratorModel::class:
$users = UserModel::where('name', 'like', '%' . $input['query'] . '%')->get();
$projectQuery = ProjectModel::where('name', 'like', '%' . $input['query'] . '%');
if (ctype_digit($input['query'])) {
$projects = $projectQuery->orWhere('id', intval($input['query']))->get();
} else {
$projects = $projectQuery->get();
}
return $this->returnMultiModels([$users->all(), $projects->all()], [new UserTransformer(), new ProjectTransformer()]);
break;
case BuyerModel::class:
$buyer = BuyerModel::where('id', $model->userable_id)->first();
$retailerId = $buyer->retailer_id;
$projectIds = \DB::table('retailer_map')->where('retailer_id', '=', $retailerId)->lists('project_id');
$projects = ProjectModel::whereIn('id', $projectIds)->where(function ($query) use($input) {
if (ctype_digit($input['query'])) {
$query->where('name', 'like', '%' . $input['query'] . '%')->orWhere('id', intval($input['query']));
} else {
$query->where('name', 'like', '%' . $input['query'] . '%');
}
})->get();
return $this->returnProjectModel($projects);
break;
case DesignerModel::class:
$projects = ProjectModel::where('user_id', $model->id)->where(function ($query) use($input) {
if (ctype_digit($input['query'])) {
$query->where('name', 'like', '%' . $input['query'] . '%')->orWhere('id', $input['query']);
} else {
$query->where('name', 'like', '%' . $input['query'] . '%');
}
})->get();
return $this->returnProjectModel($projects);
break;
default:
return Response();
}
}
示例11: delete
public function delete($hash)
{
$user = \Authorization::user();
return $this->wishRepository->deleteWish($user, $this->projectRepository->getByHash($hash)->id);
}