zachleigh

Hire Me

Experience

193,900

244 Best Reply Awards

  • Member Since 2 Years Ago
  • 780 Lessons Completed
  • 5 Favorites

5th August, 2017

zachleigh left a reply on Any Tutorials On Laravel Blog • 2 weeks ago

zachleigh left a reply on How To Add Additional Librery To Bootsrap Js • 2 weeks ago

bootstrap.js is just a js file that you can use to load up libraries etc. It is included at the top of app.js so anything you put in there will be done before the rest of your js.

zachleigh left a reply on How To Redirect To Another Controller Action? • 2 weeks ago

Just tried my above code and it works fine here.

zachleigh left a reply on How To Redirect To Another Controller Action? • 2 weeks ago

But the index method works fine?

zachleigh left a reply on How To Redirect To Another Controller Action? • 2 weeks ago

Does this work?

public function find(Request $request) {
    return $this->index($request, $events, $searchConf);
}

This will work in other frameworks. Not sure about Laravel, but I don't see any reason why it wont.

zachleigh left a reply on Method Not Loading • 2 weeks ago

Glad you got it working!

zachleigh left a reply on How To Add Additional Librery To Bootsrap Js • 2 weeks ago

Did you initiate it anywhere? From the docs:

new WOW().init();

zachleigh left a reply on Method Not Loading • 2 weeks ago

What does this do?

$this->submission->generateReport();

zachleigh left a reply on Method Not Loading • 2 weeks ago

What happens when you call the handle method?

zachleigh left a reply on Echo Result From Table To Blade • 2 weeks ago

What value do you get if you dump our $stove->stove_defra?

{{ dd($stove->stove_defra }}

31st July, 2017

zachleigh left a reply on How To Use Trim When I Used Validation In Laravel ? • 2 weeks ago

Please be more specific and show us your code.

zachleigh left a reply on How To Handel BadMethodCallException • 2 weeks ago

Please show us Handler.php.

zachleigh left a reply on Better Web Dev Workflow • 2 weeks ago

What specifically are you struggling with?

30th July, 2017

zachleigh left a reply on Upload Files To Production Server • 3 weeks ago

Use git. Its a great way to update your site.

29th July, 2017

zachleigh left a reply on Laravel 5.4 File Put Content • 3 weeks ago

What do your permissions look like? ls -l in console.

zachleigh left a reply on Laravel 5.4 File Put Content • 3 weeks ago

Dont use 777 on a production server.

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

zachleigh left a reply on Run "where Like" In A Table Inserted With The "with" • 3 weeks ago

You should use a join instead of eager loading. https://laravel.com/docs/master/queries#joins

zachleigh left a reply on Laravel Unwanted Stuff Grrrr • 3 weeks ago

You can do whatever you want :) bootstrap.js is simply a file to load up js libraries. Remove it if you don't want it. If you don't want to use laravel mix, the yes, you can remove all associated files. Id recommend keeping that though. It makes building front end stuff a breeze. But, its entirely up to you.

zachleigh left a reply on Laravel Unwanted Stuff Grrrr • 3 weeks ago

Remove whatever you dont want from package.json before running npm install. Then just delete the unwanted stuff from bootstrap.js and app.js.

This is a common complaint and is being dealt with in Laravel 5.5: https://laracasts.com/series/whats-new-in-laravel-5-5/episodes/4

zachleigh left a reply on Call JS Function At The End Of The Page (AJAX Session Check) • 3 weeks ago

You can use remember me to prevent users from having to log in again. This works, but the csrf token can still expire. For this you can try something like Caffine: https://caffeine.forlaravel.com

zachleigh left a reply on Graphic Chart • 3 weeks ago

Check out the getting started documentation: http://www.chartjs.org/docs/latest/

zachleigh left a reply on Call JS Function At The End Of The Page (AJAX Session Check) • 3 weeks ago

@if (Auth::check())
<script type="text/javascript">
    $(document).ready(function() {
        console.log("ping");
        checkSession();
    });
</script>
@endif 

Wouldn't you be just double checking auth?

zachleigh left a reply on Mysql Connection Error • 3 weeks ago

This could be due to several reasons. Most common is that the sock file doesnt exist. Verify that the file '/tmp/mysql.sock' exists and if it doesn't, see if one exists elsewhere on your system. If you have one somewhere else, set the correct file path in my.cnf.

zachleigh left a reply on Graphic Chart • 3 weeks ago

An easy solution would be to use a js charting library chart.js.

zachleigh left a reply on Provide A Reason That A Video/series Has Been Archived • 3 weeks ago

As far as I know, all series are archived when they cease to be relevant. That Vue series was archived not necessarily because Jeff made a new one, but because it was based on an outdated version of Vue. All other archived series that I know about are the same. I suppose Jeffery is the only one can really answer this one though...

19th July, 2017

zachleigh left a reply on BelongsTo • 1 month ago

How about this:

foreach (Tickets::all() as $ticket) {
    var_dump($ticket->tcode_id);
}

dd('finished');

Did all the tickets have a tcode instance?

zachleigh left a reply on How Do I Retrieve The Currently Logged In Email Address And Send A Mail... • 1 month ago

Have you red the documentation about the from method?

https://laravel.com/docs/master/mail#writing-mailables

Not sure, but maybe you could configure this in the mail class?

zachleigh left a reply on Call To A Member Function IsAdmin() On Null • 1 month ago

Might need to use the full class path:

\App\Models\User::existsAndAdmin()

Which makes it just as ugly as the first solution. Id go with a helper function.

zachleigh left a reply on Loading Class In A Service Provider • 1 month ago

Why not just new one up?

public function boot()
{
    $test = new \Acme\Core\Universal();
    $theme = $test::getTheme();
        
    //Base Theme
        $this->app->view->composer('themes.base.layouts.default', 'Acme\Composers\EcommHeaderComposer');
        $this->app->view->composer('themes.base.layouts.default', 'Acme\Composers\NavFooterComposer');
    }

zachleigh left a reply on How Do I Retrieve The Currently Logged In Email Address And Send A Mail... • 1 month ago

Is the email address on the user model? If so, you can simply do this:

Auth::user()->email

zachleigh left a reply on Loading Class In A Service Provider • 1 month ago

Which class cannot be found?

zachleigh left a reply on BelongsTo • 1 month ago

Probably because if there is no tcode for a ticket, $ticket->tcodes returns null.

zachleigh left a reply on Call To A Member Function IsAdmin() On Null • 1 month ago

Something like this would probably work:

use Auth;

//

public static function existsAndAdmin()
{
    $user = Auth::user();

    if ($user && $user->isAdmin()) {
        return true;
    }

    return false;
}

Then you can call it in your code like this:

@if (User::existsAndAdmin())

Maybe not the best solution, but it works.

You could also use a null User object. There's a video on the site somewhere about that. Ill see if I can find it...

zachleigh left a reply on BelongsTo • 1 month ago

Were you getting an error before? What was wrong with it?

zachleigh left a reply on Getting The Following Error This Dependency Was Not Found: FS • 1 month ago

Did you run npm install --save fs?

zachleigh left a reply on Sorting Array Of Objects • 1 month ago

What have you tried so far?

zachleigh left a reply on Call To A Member Function IsAdmin() On Null • 1 month ago

If there is no authenticated user, Auth::user() returns null. Could do something like this:

@if (Auth::user() && Auth::user()->isAdmin())

Kind of ugly. I'd probably make a helper function or a static method on the User model to make that a little easier.

zachleigh left a reply on Loading Class In A Service Provider • 1 month ago

What does your service provider look like?

zachleigh left a reply on BelongsTo • 1 month ago

Try reversing your relationship methods.

Ticket:

public function tcodes()
{
    return $this->hasOne(Tcode::class);
}

Tcode:

public function tickets()
{
    return $this->belongsTo(Ticket::class);
}

zachleigh left a reply on Show/Hide Pages Dynamically Based On ROLES • 1 month ago

Do it all in the database and make a web front end for it. In the db, associate roles with uri strings. Then check for the roles in middleware.

zachleigh left a reply on BelongsTo • 1 month ago

What do your migrations look like?

zachleigh left a reply on Show/Hide Pages Dynamically Based On ROLES • 1 month ago

Instead of an isAdmin method, how about an hasRole method?

Auth::user()->hasRole(['admin', 'moderator' ])

18th July, 2017

zachleigh left a reply on How To Get Data From User Before The View Loads • 1 month ago

Run the client side script when the user clicks on the button and send the data as part of the request. Return the view as you normally would.

zachleigh left a reply on Trying To Figure Out Why To Type Hint A Parameter When It Is Already In The Proper Format. • 1 month ago

Type hints arent necessary, and some people dont even find them useful. (There was a whole Twitter thing about this not too long ago.) Type hints are merely a way of checking that a parameter is what you expect it to be. In your example, if you pass a User instance, the type hint will be satisfied and the code will continue to run. If you pass something that is not a User instance, php will throw a fatal error and your code will stop.

Type hints can be useful because they give you a way to catch potential bugs early before things get really ugly and difficult to debug. Some people dont find them necessary because, like you experienced, the code runs fine without them. So really, its totally up to you if you want to use them or not.

17th July, 2017

zachleigh left a reply on Best Ways To Refactor A Controller • 1 month ago

First, I dont think I'd use localized request keys. Seems troublesome and pointless.

I would make filter classes for all the different filters and I would automate all the calls to those filters. Currently, you are doing if (Request::has(trans('key_name'))) all over the place. Would be much cleaner to simply loop through the request variables and then call the necessary filter class if it existed. Something like this:

$search = $entries->whereHas('clinic', function ($query) {
    $query->where('status_id', 12);
})->orderBy('rating', 'desc');

foreach ($request->all() as $variable) {
    $filterName = 'Full\\Namespace\\' . ucfirst($variable) . 'Filter';

    if (class_exists($filterName) {
        $filter = new $filtername();

        $filter->apply($search);
    }
}

That way all your filters could have their own classes and the controller would be simple.

zachleigh left a reply on How Would I Highlight The Last Updated Data In The Laravel View Blade • 1 month ago

Use an updated_at database column.

zachleigh left a reply on How To Add Name Route Action In Resource Controller? • 1 month ago

From the docs:

Route::resource('photo', 'PhotoController', ['names' => [
    'create' => 'photo.build'
]]);

Link: https://laravel.com/docs/master/controllers#resource-controllers

zachleigh left a reply on Testing Api With Api Middleware Need Your Help • 1 month ago

Try not chaining your methods.

$this->actingAs($user, 'api');
$this->json('POST', '/folders', $this->fake_folder());
$this->assertStatus(200);

zachleigh left a reply on How To Add/update Json In Data Cell • 1 month ago

What exactly do you want to do?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.