本文整理汇总了PHP中Illuminate\Auth\Guard::id方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::id方法的具体用法?PHP Guard::id怎么用?PHP Guard::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Auth\Guard
的用法示例。
在下文中一共展示了Guard::id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created snippet in storage.
*
* @param SnippetsRequest $request
* @return Response
*/
public function store(SnippetsRequest $request)
{
$this->auth->basic('username');
$data = ['title' => $request->input('title') ?: null, 'user_id' => $this->auth->user() ? $this->auth->id() : null, 'password' => $request->input('password') ?: null, 'mode' => $request->input('mode') ?: 'markdown'];
$snippet = $this->dispatchFrom(StoreNewSnippetCommand::class, $request, $data);
return 'http://drk.sh/s/' . $snippet->slug->slug . PHP_EOL;
}
示例2: handle
/**
* Handle the command.
*
* @param Guard $auth
*/
public function handle(Guard $auth)
{
if ($this->entry->created_at) {
$this->entry->updated_at = time();
$this->entry->updated_by = $auth->id();
}
if (!$this->entry->created_at) {
$this->entry->created_at = time();
$this->entry->created_by = $auth->id();
}
if (!$this->entry->sort_order) {
/* @var Builder $query */
$query = $this->entry->newQuery();
$this->entry->sort_order = $query->count('id') + 1;
}
}
示例3: submit
public function submit($id, Request $request, Guard $auth)
{
$this->validate($request, ['comment' => 'required|max:250', 'link' => 'url']);
$comment = new TicketComments($request->only('comment', 'link'));
$comment->user_id = $auth->id();
$ticket = Ticket::findOrFail($id);
$ticket->comments()->save($comment);
session()->flash('success', 'Tu comentario fue guardado exitosamente');
return redirect()->back();
}
示例4: nuevo
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function nuevo($id, Request $request, Guard $auth)
{
$this->validate($request, ['comentario' => 'required|max:250', 'link' => 'url']);
$comentario = new TicketComentario($request->all());
$comentario->user_id = $auth->id();
$ticket = Ticket::findOrFail($id);
$ticket->comentarios()->save($comentario);
session()->flash('success', 'Comentario guardado correctamente');
return redirect()->back();
//$comentario = new TicketComentario($request->only(['comentario', 'link']));
}
示例5: getImportJobByUser
/**
* Get Import Job by User
*
* @return array
*/
public function getImportJobByUser()
{
$dirs = $this->filesystem->directories($this->getFilePath());
$user_key = [];
if (empty($dirs)) {
return $user_key;
}
foreach ($dirs as $dir) {
$key = last(explode('/', $dir));
$json = $this->getJsonData($key, false);
if (empty($json)) {
continue;
}
$contracts = $json->contracts;
if (isset($contracts[0]->user_id) && $contracts[0]->user_id == $this->auth->id()) {
$user_key[] = ['step' => $json->step, 'key' => $key, 'is_completed' => $this->isImportCompleted($key), 'file' => $this->getOriginalFileName($key)];
}
}
return $user_key;
}
示例6: set
/**
* Set a preference value.
*
* @param $key
* @param $value
* @return $this
*/
public function set($key, $value)
{
$preference = $this->model->where('user_id', $this->auth->id())->where('key', $key)->first();
if (!$preference) {
$preference = $this->model->newInstance();
$preference->user_id = $this->auth->id();
$preference->key = $key;
}
if (!($field = config(str_replace('::', '::preferences/preferences.', $key)))) {
$field = config(str_replace('::', '::preferences.', $key));
}
if (is_string($field)) {
$field = ['type' => $field];
}
$type = app(array_get($field, 'type'));
$modifier = $type->getModifier();
if ($modifier instanceof FieldTypeModifier) {
$value = $modifier->modify($value);
}
$preference->value = $value;
$preference->save();
return $this;
}
示例7: id
/**
* Get the ID for the currently authenticated user.
*
* @return int|null
* @static
*/
public static function id()
{
return \Illuminate\Auth\Guard::id();
}
示例8: handle
/**
* Handle the form fields.
*
* @param Guard $auth
* @param PostFormBuilder $builder
*/
public function handle(Guard $auth, PostFormBuilder $builder)
{
$builder->setFields(['*', 'author' => ['config' => ['default_value' => $auth->id()]], 'publish_at' => ['config' => ['default_value' => 'now']]]);
}
示例9: save
/**
* @param $activityLog
* @param string $user_id
* @return bool
*/
public function save($activityLog, $user_id = null)
{
$activityLog['user_id'] = is_null($user_id) ? $this->auth->id() : $user_id;
return $this->activityLog->create($activityLog) ? true : false;
}