schir1964

schir1964

Member Since 4 Years Ago

Experience Points
7,840
Total
Experience

2,160 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
67
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
7,840 XP
Nov
29
2 years ago
Activity icon

Replied to PHP Regular Expression

I think you are over thinking it. The result you want is to replace the string that follows 'phone number' and is before '. My' sections of the text.

So how about the following:

preg_replace('/phone number .*\. My/', 'phone number [blocked]. My', $msg);
May
10
3 years ago
Activity icon

Replied to Large Database, Slow Query Suggestions?

You could create a Database View containing the mutated values and then have a separate model for that table. Should be able to search/sort on those fields then. Just a thought.

May
02
3 years ago
Activity icon

Replied to 1 Or 2 Tables With 5.2 Guards/ACL

I went with Roles and Permissions tables. I needed the flexibility. There's more layers than just users and admins. Theres various levels of administration that I needed to set authorization for.

For example:

  • I have a developer role that allows for creating sales representative type adminstrators.
  • I have a sales representatives role that allows for creating user accounts.
  • I have a billing role that allows access to billing user accounts but little else.

There's a Laracast that discusses ACL and one of sections shows how to set up Roles and Permissions. Much simpler to set it up than I thought it would be.

As for the Login: 1 Login screen. Those that have higher levels of authorization have extra menu items that lead to more restricted areas of the website.

Apr
14
3 years ago
Activity icon

Replied to How Increase Uploading File Size In Laravel.

Check your php.ini file. There's another configuration setting that can affect the upload but the details escape me now.

Apr
13
3 years ago
Activity icon

Replied to Multiple OrderBy On Query

I discovered this on one of Jeffrey's videos that shows how to handle this outside of the model.

$model = (new Model)->newQuery();

foreach ($request->get('sort_criteria') as $column => $direction) {
    $model->orderBy($column, $direction);
}

$results = $model->paginate(10);
Apr
11
3 years ago
Activity icon

Replied to Multiple OrderBy On Query

After reading some more of the Eloquent documentation I discovered that a Dynamic Scope is normally used for this kind of thing. I created a dynamic scope to handle adding the Sort criteria one by one using the orderBy command. Basically it serves as a custom Query Builder command.

Dynamic Scope on Model

public function scopeOfSort($query, $sort)
{
    foreach ($sort as $column => $direction) {
        $query->orderBy($column, $direction);
    }

    return $query;
}

Dynamic Scope Usage

$results = $model->ofSort($sort_criteria)->paginate(10));

This worked as expected.

Apr
10
3 years ago
Activity icon

Replied to Let Admin "take Over" User Feature

One technique I've used (not for Laravel specifically) is to have a flag on the Users account that allows the vendor to login to the users account. This flag is controlled by the user. They can toggle access by the vendor on and off within their account. Then all you need is a vendor hash for each account stored in the database somewhere (or even have it generated on the fly if needed) that is checked during the login process. The vendor's support screen only shows a login button for those accounts that have allowed vendor access. This has worked well with the particular web application I was supporting.

Note: This doesn't help if the issue is that that the user can't get logged into their account or is unable to move around within their account.

Activity icon

Started a new conversation Multiple OrderBy On Query

Is there a way to set multiple orderBy criteria when querying from a model without chaining the commands.

Chaining (Works)

$result = $model->orderBy('name', 'asc')->orderBy('id', 'asc')->paginate(10);

No Chaining (Does not work)

$model->orderBy('name', 'asc');
$model->orderBy('id', 'asc');
$result = $model->paginate(10);

I'm receiving the sort criteria from table headers so chaining becomes difficult since the sort criteria changes (number of sort fields).

How is this handled generally?

Apr
07
3 years ago
Activity icon

Replied to Composer Update: Script Php Artisan Clear-compiled Handling The Pre-update-cmd Event Returned With An Error

I get this error whenever I try to run composer update and don't have my Web Server and Database Server up and running.

Mar
18
3 years ago
Activity icon

Started a new conversation Laravel Website Down?

What is going on with www.laravel.com website. It's been down for the last day I think.

Mar
15
3 years ago
Activity icon

Started a new conversation Foundation 6 Presenter For Paginator

Illuminate\Pagination class works really well but only has Presenters for Bootstrap. I decided to take a crack at making a Presenter for Foundation 6 and amazingly it only took about an hour of actual code changes (a few more for reading and analyzing the code).

Anyway, I copied the following two files to my App directory and renamed them and made the necessary changes for implementation and Foundation 6 styles.

  • laravel/framework/src/Illuminate/Pagination/BootstrapThreePresenter.php
  • laravel/framework/src/Illuminate/Pagination/BootstrapThreeNextPreviousButtonRendererTrait.php

Just save the following two files into your App directory and then in your Blade template you simply pass in the Presenter to your Pagination object (usually instantiated in the controller and passed into the template).

Blade: Passing Presenter Into Paginator Object

{!! $paginatorObj->links(new \App\Foundation6Presenter($paginatorObj)) !!}

Foundation6Presenter.php

<?php

namespace App;

use Illuminate\Support\HtmlString;
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
use Illuminate\Contracts\Pagination\Presenter as PresenterContract;
use Illuminate\Pagination\UrlWindowPresenterTrait;
use Illuminate\Pagination\UrlWindow;

class Foundation6Presenter implements PresenterContract
{
    use Foundation6NextPreviousButtonRendererTrait, UrlWindowPresenterTrait;

    /**
     * The paginator implementation.
     *
     * @var \Illuminate\Contracts\Pagination\Paginator
     */
    protected $paginator;

    /**
     * The URL window data structure.
     *
     * @var array
     */
    protected $window;

    /**
     * Create a new Bootstrap presenter instance.
     *
     * @param  \Illuminate\Contracts\Pagination\Paginator  $paginator
     * @param  \Illuminate\Pagination\UrlWindow|null  $window
     * @return void
     */
    public function __construct(PaginatorContract $paginator, UrlWindow $window = null)
    {
        $this->paginator = $paginator;
        $this->window = is_null($window) ? UrlWindow::make($paginator) : $window->get();
    }

    /**
     * Determine if the underlying paginator being presented has pages to show.
     *
     * @return bool
     */
    public function hasPages()
    {
        return $this->paginator->hasPages();
    }

    /**
     * Convert the URL window into Bootstrap HTML.
     *
     * @return \Illuminate\Support\HtmlString
     */
    public function render()
    {
        if ($this->hasPages()) {
            return new HtmlString(sprintf(
                '<ul class="pagination text-center" role="navigation" aria-label="Pagination">%s %s %s</ul>',
                $this->getPreviousButton(),
                $this->getLinks(),
                $this->getNextButton()
            ));
        }

        return '';
    }

    /**
     * Get HTML wrapper for an available page link.
     *
     * @param  string  $url
     * @param  int  $page
     * @param  string|null  $rel
     * @return string
     */
    protected function getAvailablePageWrapper($url, $page, $rel = null)
    {
        $rel = is_null($rel) ? '' : ' rel="'.$rel.'"';

        return '<li><a href="'.htmlentities($url).'"'.$rel.' aria-label="Page '.$page.'">'.$page.'</a></li>';
    }

    /**
     * Get HTML wrapper for disabled text.
     *
     * @param  string  $text
     * @return string
     */
    protected function getDisabledTextWrapper($text)
    {
        return '<li class="disabled">'.$text.'</li>';
    }

    /**
     * Get HTML wrapper for active text.
     *
     * @param  string  $text
     * @return string
     */
    protected function getActivePageWrapper($text)
    {
        return '<li class="current"><span class="show-for-sr">You&#39;re on page </span>'.$text.'</li>';
    }

    /**
     * Get a pagination "dot" element.
     *
     * @return string
     */
    protected function getDots()
    {
        return '<li class="ellipsis"></li>';
    }

    /**
     * Get the current page from the paginator.
     *
     * @return int
     */
    protected function currentPage()
    {
        return $this->paginator->currentPage();
    }

    /**
     * Get the last page from the paginator.
     *
     * @return int
     */
    protected function lastPage()
    {
        return $this->paginator->lastPage();
    }
}

Foundation6NextPreviousButtonRendererTrait.php

<?php

namespace App;

trait Foundation6NextPreviousButtonRendererTrait
{
    /**
     * Get the previous page pagination element.
     *
     * @param  string  $text
     * @return string
     */
    public function getPreviousButton($text = '«')
    {
        // If the current page is less than or equal to one, it means we can't go any
        // further back in the pages, so we will render a disabled previous button
        // when that is the case. Otherwise, we will give it an active "status".
        if ($this->paginator->currentPage() <= 1) {
            return '<li class="pagination-previous disabled">Previous</li>';
        }

        $url = $this->paginator->url($this->paginator->currentPage() - 1);

        return '<li class="pagination-previous"><a href="'.htmlentities($url).'" aria-label="Previous page">Previous</a></li>';
    }

    /**
     * Get the next page pagination element.
     *
     * @param  string  $text
     * @return string
     */
    public function getNextButton($text = '»')
    {
        // If the current page is greater than or equal to the last page, it means we
        // can't go any further into the pages, as we're already on this last page
        // that is available, so we will make it the "next" link style disabled.
        if (! $this->paginator->hasMorePages()) {
            return '<li class="pagination-next disabled">Next</li>';
        }

        $url = $this->paginator->url($this->paginator->currentPage() + 1);

        return '<li class="pagination-next"><a href="'.htmlentities($url).'" aria-label="Next page">Next</a></li>';
    }
}
Feb
23
3 years ago
Activity icon

Replied to Uploads To Cloud

I would like to do it with PHP but If I use their php lib I believe it is the same thing i.e. it would save image in /tmp and then I would have to move it to Transloadit and then from there into S3 or rackspace.

Actually, it doesn't. I've implemented this service for a project and the files are never stored on your server (even temporarily). What happens is the jQuery code connects to thier servers via an API and the file uploads onto thier servers. Once that is done the jQuery then updates the form with the file's reference information from transloadit and then submits the form on your website. If you want the direct link to where this is explained in their documentation I can provide it if needed.

Activity icon

Replied to Unexplainded TokenMismatchException

You can also get this error when the session times out and you submit a form that has been sitting there. There is another thread that talks about this. But may not have anything to do with your particular issue.

Activity icon

Replied to Uploads To Cloud

Is it possible to have the image file be originally uploaded to cloud server instead of the /tmp location on local server?

It is possible but it needs to be setup external from your own code. The Transloadit service is an example of an external service that your code can use to handle the uploading of files and storing them on cloud storage (such as Amazon's S3).

Feb
17
3 years ago
Activity icon

Replied to How To Solve Logical Problem With Blade

@if ($article->from > Carbon::now()->addDays($article->days))
    @if (($article->from > $win->start) || (Carbon::now()->addDays($article->days) > $win->start))
        <div>get VOUCHER</div>
    @else
        <div>ACTIVE</div>
    @endif
@endif

Yes, what Snapey said below. All the logic here could be moved into the model and have it return a true or false for Voucher or Active depending on how you define it.

Feb
16
3 years ago
Activity icon

Replied to A Div Dynamically From A Controller

Minor alteration to keep as much of the html code out of the controller.

Controller

$faName = 'home';

View

<i class="fa-fw fa fa-{{ $faName }}"></i>

Just a thought.

Feb
15
3 years ago
Activity icon

Replied to Pagination Page # For Specific Record By ID?

You could create a method on the Company model that would return the proper paginated page number.

This method would create the sorted list containing just the id column.

Transform sorted list to a simple array.

Determine the index (position) of the item in the array (not by the id).

Then the method could determine which page the id would be shown and return that page number.

This routine would add a lot of overhead your code if it has to be called much.

Feb
14
3 years ago
Activity icon

Replied to Auth Middleware On Post Route

You'll probably want to use use the flash() or reflash() method to pass the information on to the next request. Search for reflash in the documentation.

Activity icon

Replied to User Registration Email Confirmation Issue

Another note: I used this same tutorial to get my email confirmation working with my project. I had to massage certain parts of the code since that tutorial is based on Laravel 4 and I'm using Laravel 5.2 version. There's some significant differences in certain areas as to how things get done. I did have to pause and research each of these areas to resolve the differences.

Activity icon

Replied to Check If Cookie Exists In Create() Function

Isn't there a Cookie::has('affiliate_id') method that checks for the existence?

Activity icon

Replied to Handling Errors For Register And Login Forms On The Same Page

Check the section called 'Named Error Bags' in the documentation under Validation.

Note: The names of the input fields can be the same in each of the forms, however, if you are using ids with the input fields they need to be unique for the entire web page.

Feb
11
3 years ago
Activity icon

Replied to Update Part Of The View Using AJAX

If you want to use blade you can just create the HTML in a blade file then return that view as you would normally. This is how a lot of the email is done. The email blade file is just partial HTML file that is used to create the body of the message.

Feb
03
3 years ago
Activity icon

Replied to Cascading Soft Deletes

What is the goal in achieving this?

Are wanting mark all child items as Soft Deleted also? What is the benefit in doing this?

If the child items are being referenced outside of the parent item, then I think it might make more sense to add a method to the model of the child item that returns the soft delete indicator of the parent which can used as needed.

Dec
26
3 years ago
Activity icon

Replied to L5.1 Roles And Permissions Call To Undefined Method HasRole()

I think I narrowed down your problem to the hasPermission() method.

I actually implemented your solution because I was trying to do the same thing but you did it so much better! (8^D)

In your AuthServiceProvider class abov e (line 30):

            return $user->hasPermission($permission);

change to

            return $user->hasRole($permission->roles());

That worked for me. Thanks for all your hard work.