本文整理汇总了PHP中Illuminate\Support\Facades\Auth::id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::id方法的具体用法?PHP Auth::id怎么用?PHP Auth::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: closeEditor
public function closeEditor(Request $request)
{
$dbxClient = $this->getDropboxClient();
$LocalAddress = $request->input('LocalAddress');
$LocalName = $request->input('LocalName');
$DropBoxFile = $request->input('DropBoxFile');
// $dropboxFileName = $request->input('fileName');
file_put_contents($LocalAddress, $_POST['text']);
$editContent = array();
$editContent[0] = htmlspecialchars($_POST['text']);
//updated text
$editContent[1] = $LocalAddress;
// full local folder name with location
$editContent[2] = $LocalName;
//full local file name
$editContent[3] = $DropBoxFile;
//full dropbox path with name
$LocalName = str_replace(' ', '', $LocalName);
$f = fopen($editContent[1], "rb");
$result = $dbxClient->uploadFile($editContent[3], dbx\WriteMode::force(), $f);
fclose($f);
$dropboxObject = Dropbox::where('userId', Auth::id())->firstOrFail();
$access_token = $dropboxObject->accessToken;
$dropboxClient = new dbx\Client($access_token, "PHP-Example/1.0");
$folderMetadata = $dropboxClient->getMetadataWithChildren("/");
$this->deleteFile($LocalAddress);
return view('pages.dropbox')->with('dropboxData', $folderMetadata);
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$taches = Tache::all();
$test = true;
foreach ($taches as $tache) {
if ($tache->sprint_id == $id) {
if ($tache->developer_id == Auth::id() && $tache->state == 1) {
$tache->update(['state' => 2]);
$tachesn = Tache::where('us_story_id', $tache->us_story_id)->get();
foreach ($tachesn as $tachen) {
if ($tachen->state != 2) {
$test = false;
break;
}
}
$userstory = Userstory::findOrFail($tache->us_story_id);
/* if($test == true){
$userstory->update(['status'=> 1]);
}
else{
$userstory->update(['status'=> 0]);
}*/
}
}
}
return redirect(route('kanban.taches.show', $id));
// return view('kanban.taches.show',compact('id'));
// return redirect(route('kanban.taches.index',$id));
}
示例3: persist
/**
* Save the changes.
*
* @param Issue $issue
*
* @return bool
*/
public function persist(Issue $issue)
{
$issue->user_id = $issue->exists ? $issue->user_id : Auth::id();
$issue->title = $this->input('title', $issue->title);
$issue->description = $this->input('description', $issue->description);
$issue->occurred_at = $this->input('occurred_at', $issue->occurred_at);
if ($issue->save()) {
// Check if we have any files to upload and attach.
if (count($this->files) > 0) {
foreach ($this->file('files') as $file) {
if (!is_null($file)) {
$issue->uploadFile($file);
}
}
}
// Sync the issues labels.
$labels = $this->input('labels', []);
if (is_array($labels)) {
$issue->labels()->sync($labels);
}
// Sync the issues users.
$users = $this->input('users', []);
if (is_array($users)) {
$issue->users()->sync($users);
}
return true;
}
return false;
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::id() != 1) {
return redirect('/');
}
return $next($request);
}
示例5: adminOrCurrentUserOwns
public function adminOrCurrentUserOwns($modelRecord)
{
if (Auth::user()->isAdmin()) {
return true;
}
return $modelRecord->user_id === Auth::id();
}
示例6: isAdmin
public function isAdmin()
{
if (Cache::has('role.' . Auth::id()) && Cache::get('role.' . Auth::id()) === 'admin') {
return true;
}
return false;
}
示例7: store
/**
* Upload the file and store
* the file path in the DB.
*/
public function store()
{
// Rules
$rules = array('name' => 'required', 'file' => 'required|max:20000');
$messages = array('max' => 'Please make sure the file size is not larger then 20MB');
// Create validation
$validator = Validator::make(Input::all(), $rules, $messages);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$directory = "uploads/files/";
// Before anything let's make sure a file was uploaded
if (Input::hasFile('file') && Request::file('file')->isValid()) {
$current_file = Input::file('file');
$filename = Auth::id() . '_' . $current_file->getClientOriginalName();
$current_file->move($directory, $filename);
$file = new Upload();
$file->user_id = Auth::id();
$file->project_id = Input::get('project_id');
$file->name = Input::get('name');
$file->path = $directory . $filename;
$file->save();
return Redirect::back();
}
$upload = new Upload();
$upload->user_id = Auth::id();
$upload->project_id = Input::get('project_id');
$upload->name = Input::get('name');
$upload->path = $directory . $filename;
$upload->save();
return Redirect::back();
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//return $request->all();
$changerequest = new ChangeRequest();
$changerequest->subject_id = $request->subject_id;
$changerequest->subject_type = $request->subject_type;
$changerequest->subject_name = Breadcrumbs::getSubjectName($request->subject_type, $request->subject_id);
$changerequest->external_id = $request->external_id;
$changerequest->status = $request->status;
$changerequest->title = $request->title;
$changerequest->description = $request->description;
$changerequest->sponsor = $request->sponsor;
$changerequest->contact = $request->contact;
$changerequest->submission_date = Carbon::parse($request->submission_date)->toDateTimeString();
$changerequest->required_by = Carbon::parse($request->required_by)->toDateTimeString();
$changerequest->lead_time = $request->lead_time;
$changerequest->implementation_date = Carbon::parse($request->implementation_date)->toDateTimeString();
$changerequest->ranking = $request->ranking;
$changerequest->business_benefit = $request->business_benefit;
$changerequest->business_impact = $request->business_impact;
$changerequest->impact_analysis = $request->impact_analysis;
$changerequest->created_by = Auth::id();
$changerequest->save();
flash()->success('Success', "New Change Request created successfully");
return redirect(Session::GetRedirect());
}
示例9: destroy
/**
* Unfallow a User
*
* @param $userIdToUnfallow
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($userIdToUnfallow, Request $request)
{
$request->replace(array_add($request->all(), 'userId', Auth::id()));
$this->dispatcher->dispatchFrom(UnfallowUser::class, $request);
Flash::success('You have now unfallowed this user');
return Redirect::back();
}
示例10: store
/**
* New status comment
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->commentForm->validate($request->all());
$input = array_add($request->all(), 'user_id', Auth::id());
$this->statusRepo->leaveComment($input);
return back();
}
示例11: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$course = $this->get('course_id');
$message = trans('messages.your_application_was_sent_successfully');
Flash::info($message);
return !Application::where('course_id', $course)->where('user_id', Auth::id())->exists();
}
示例12: handle
/**
* Handle the command.
*
* @param UnFollowUserCommand $command
* @return void
*/
public function handle(UnFollowUserCommand $command)
{
//
//dd($command);
$follow = Follow::whereRaw('user_id=? AND followed_id=?', [Auth::id(), $command->userId])->firstOrFail();
$follow->delete();
}
示例13: create
public function create()
{
DB::transaction(function () {
$twitterClient = new TwitterOAuth(Config::get('services.twitter.consumerKey'), Config::get('services.twitter.consumerSecret'), Config::get('services.twitter.accessToken'), Config::get('services.twitter.accessSecret'));
// Fetch the tweet information from Twitter, if a tweet id was passed through (it is possible the tweet was created manually without an id)
if (array_key_exists('tweet_id', $this->input)) {
$tweet = $twitterClient->get('statuses/show', ['id' => $this->input['tweet_id']]);
$tweetOwner = $tweet->user;
$this->object = Object::create(['user_id' => Auth::id(), 'type' => MissionControlType::Tweet, 'tweet_text' => $tweet->text, 'tweet_id' => $tweet->id, 'tweet_parent_id' => $tweet->in_reply_to_status_id, 'size' => strlen($tweet->text), 'title' => $tweet->text, 'summary' => $this->input['summary'], 'cryptographic_hash' => hash('sha256', $tweet->text), 'originated_at' => Carbon::createFromFormat('D M d H:i:s P Y', $tweet->created_at)->toDateTimeString(), 'status' => ObjectPublicationStatus::QueuedStatus]);
} else {
$this->object = Object::create(['user_id' => Auth::id(), 'type' => MissionControlType::Tweet, 'tweet_text' => $this->input['tweet_text'], 'size' => strlen($this->input['tweet_text']), 'title' => $this->input['tweet_text'], 'summary' => $this->input['summary'], 'cryptographic_hash' => hash('sha256', $this->input['tweet_text']), 'originated_at' => $this->input['originated_at'], 'status' => ObjectPublicationStatus::QueuedStatus]);
}
try {
if (!isset($tweetOwner)) {
$tweetOwner = $twitterClient->get('users/show', ['screen_name' => $this->input['tweet_screen_name']]);
}
$tweeter = Tweeter::byScreenName($tweetOwner->screen_name)->firstOrFail();
} catch (ModelNotFoundException $e) {
$tweeter = Tweeter::create(['screen_name' => $tweetOwner->screen_name, 'user_name' => $tweetOwner->name, 'description' => $tweetOwner->description]);
$tweeter->saveProfilePicture();
}
$this->object->tweeter()->associate($tweeter);
$this->createMissionRelation();
$this->createTagRelations();
$this->object->push();
});
return $this->object;
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param FlyerRequest|Request $request
* @return Response
*/
public function store(FlyerRequest $request)
{
$input = array_add($request->all(), 'user_id', Auth::id());
$flyer = Flyer::create($input);
flash()->success('Success', 'your flyer has been created');
return Redirect::to(url('/' . $flyer->zip . '/' . $flyer->street));
}
示例15: store
public function store(OrderRequest $request)
{
$order = $request->all();
$order['user_id'] = Auth::id();
Order::create($order);
return Redirect::to("/?timer=true");
}