Snapey

at Novate / Microlise

Hire Me

Experience

448,075

714 Best Reply Awards

  • Member Since 2 Years Ago
  • 757 Lessons Completed
  • 1 Favorite

26th April, 2017

Snapey left a reply on Problem With Path When Configuring Shared Server • 1 hour ago

You should move your laravel installation to a folder above public_html and not within it.

Then follow my article (http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet/) to change the path inside index.php to tell it where to find the bootstrap code.

Snapey left a reply on <a> Tag Is Not Working In <li?> • 1 hour ago

What is not working?

25th April, 2017

Snapey left a reply on Display Data From Separate Models -- Or Should I Denormalize? • 9 hours ago

Sorry, where is the name of the station coming from?

Snapey left a reply on Auth()->attempt .... Always False • 9 hours ago

It depends very much how you stored the password in the first place.

When you look in the database, what does the password look like?

Snapey left a reply on [Form Request] Automatically Execute Action If Valid • 12 hours ago

it only makes sense if all the data in the form goes into one model and doesn't require additional processing.

Snapey left a reply on How Do I Delete All User Records Except My Current Session? • 1 day ago

What has the User model got to do with sessions?

Deleting users will not kill sessions.

Snapey left a reply on Creating A Session • 1 day ago

You load a row from the cart_session table, and then try and json_decode but it will be a laravel collection (cannot be json_decoded)

    $carts_tbl = DB::table('cart_session')->where(['customer_id' => $customer_id])->first();

    if(!empty($carts_tbl))
    {
        $cart_data = json_decode($carts_tbl->data);

24th April, 2017

Snapey left a reply on How To Carbon::praise Date Form Strange Format • 1 day ago

If its always the same number of 0 digits, I would be tempted to just str_replace that sucker.

$datetime = '2017-04-24T07:00:00.000000000Z';

$date=new Carbon\Carbon(str_replace('.000000000Z','Z',$datetime));

Snapey left a reply on Auth Middle Ware Error ERR_TOO_MANY_REDIRECTS • 1 day ago

what happens is that the login controller redirects if the user is logged in.

if you login on the / path then you can login and be redirected to / which goes to login controller which says oh, you are logged in, which redirects to /

and so on...

Snapey left a reply on View Composer → Markdown Parser Problem • 1 day ago

have you checked that the data is actually passed to the view?

you can see everything that was passed to the view with {{ dump($__data) }}

or of course you can dump the specific variable

Snapey left a reply on Forgot Your Password Doesn't Work • 1 day ago

so in the .env file you will find mail config values which should be removed if you are adding the settings in the config/mail file

Snapey left a reply on Ajax Table Update Inserts <br> In Database, Why? • 1 day ago

if the problem cannot be spotted in the code then you are going to have to start diagnosing the problem.

The first thing to do is to open up your browser developer tools, post the change and see if the format being sent to the server is correct or not.

at least then you will know if it's a client issue or a server issue

Snapey left a reply on MethodNotAllowedHttpException Ln 251 And How To Debug • 1 day ago

very, very, very first thing is to setup local hosting properly so that /blog/public is not needed in your urls

the way it is set now, you will just constantly get strange errors

as for debugging, you can see a lot in your browser with the inspector and the network tab.

if in your routes you expect to get a POST request to blog/comments, if you look in the network tools you will see the request goes to /blog/public/posts/comments which will not find a match in your routes

Snapey left a reply on Updating Form • 1 day ago

if you want examples watch the laravel from scratch series

Snapey left a reply on Forgot Your Password Doesn't Work • 1 day ago

and if you are putting the values here, did you remove them from the .env file?

Snapey left a reply on Notification Problem. • 1 day ago

please remember to put three backticks ` before and after code blocks in this forum

what is on line 19 of DatabaseChannel?

Snapey left a reply on Images Showing In Profiles.index But Not Showing In Profiles.show • 1 day ago

it's because your image path is relative to the current url because it doesn't start with a backslash

Snapey left a reply on [Form Request] Automatically Execute Action If Valid • 1 day ago

it's just one line of code

are you trying to get to totally empty controller methods?

Snapey left a reply on Where To Add Logic After Reset Password. • 1 day ago

Check the title of your question.....

Snapey left a reply on Seperating Html File And Laravel Framework • 1 day ago

read it again

the request starts at index.php and then is processed by routes.php where the application routes are defined. This will then pass to a controller which will return content or return a redirect to another view.

You MUST learn what MVC is and not use resources from 10 years ago to write PHP

Snapey left a reply on Ajax Table Update Inserts <br> In Database, Why? • 1 day ago

Try putting the whole <td></td> on the same line

Snapey left a reply on Blade Templates • 2 days ago

and mysql and php and getting development environment setup... It would be cheaper to pass the client to someone else.

Snapey left a reply on Database Builder • 2 days ago

maybe you don't have a database? You seem pretty clueless so I would not be surprised.

Snapey left a reply on Seperating Html File And Laravel Framework • 2 days ago

index.php is supplied by the framework. This is not where your code goes.

It also has nothing to do with index.blade.php

23rd April, 2017

Snapey left a reply on Ajax Table Update Inserts <br> In Database, Why? • 2 days ago

what does the form look like?

which field gets the extra break?

Snapey left a reply on Database Builder • 2 days ago

I would recommend putting all your database access through models

Snapey left a reply on Laravel Debug-bar • 2 days ago

both. there is no point in including the library in your production code if it never gets run.

Snapey left a reply on Ajax Table Update Inserts <br> In Database, Why? • 2 days ago

blimey, I remember code like this. I had more hair then though.

what does the girl look like?

which field gets the extra break?

Snapey left a reply on Displaying Stored Images On Shared Hosting • 2 days ago

you can create a new disk in the config (or change the existing disk).Sorry, I'm on iPad at the moment so don't know exactly but I think it is in config/storage.php

Snapey left a reply on Displaying Stored Images On Shared Hosting • 2 days ago

it's no different since the symlink makes the folder externally accessible anyway

Snapey left a reply on Conditional Email Validation • 2 days ago

@jaytee you can see what is sent in the browser network tools it will be the value or 'on' if checked, otherwise it's not present in the post

Snapey left a reply on Displaying Stored Images On Shared Hosting • 2 days ago

...or store your files in the public folder?

Snapey left a reply on Conditional Email Validation • 2 days ago

@jaytee the value is whatever value= is set to on the checkbox field. if value=1 then it will be 1 or missing.

If value is not specified then the value is on or missing

Snapey left a reply on Problem In Showing Errors In Right Place • 2 days ago

you should NOT identify that the password is wrong. This is why the error does not mention password. All you should know is that the combination of username and password do not match.

It's bad security practice to callout that a valid username was provided.

Snapey left a reply on Displaying Stored Images On Shared Hosting • 2 days ago

you need to be able to create a symlink from storage/app/public to your external, public area

Snapey left a reply on Seperating Html File And Laravel Framework • 2 days ago

What you see is the best practice. You should not have any html files as all the content should be served by the framework through the index.php page.

Do yourself a favour and setup a new test site and have a play around before you go pulling someone else code apart.

Snapey left a reply on Form Model Binding Related Many To Many Models • 2 days ago

The behaviour is broken because unchecked fields are not present in the form data so if you uncheck and then reshow the form, old() has no choice but to fall back to the model state.

Snapey left a reply on Mac Mini As Dev Box? • 2 days ago

I've not run any tests with HDD but its snappy in all respects

Snapey left a reply on Mac Mini As Dev Box? • 2 days ago

I've had two mac mini's and they have been great. I upgraded to 2 x SSD drives (one is a straight swap, the other needs a kit (OWC: https://eshop.macsales.com/item/OWC/DIYIMM11D2/)

Monitors are BenQ 21" and Dell U2913. the Dell was a bit pricy and to be honest its a little too wide for my eyes, and not deep enough (2560x1040)

If apple brought out a new model I'd probably buy it. My current machine is Late 2012 model (2.5GHX i5). its plenty fast enough but its time for replacement.

Go for 16GB, however with Valet, the only time I fire up virtual box is to run windows7!

Snapey left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 2 days ago

I have a database of dogs with dates of birth (as Date column) so I knocked up this query to get birthdays in the next 7 days.

This gets them all in one query;

    $dt = new Carbon\Carbon;

    // where birthday is today
    $birthdays = App\Dog::where('DOB','like',$dt->format('%-m-d'));

    // where birthday is on one of the next 6 days.  Uses addDays to 
    // step through the calendar (allowing for month end and year end
    
    foreach (range(1, 6) as $number) {
        $birthdays->orWhere('DOB','like',$dt->addDays(1)->format('%-m-d'));
    }
    
    $upcomingBirthdays = $birthdays->get();

A couple of things to call out

  • This is using like and the % operator to ignore the year
  • The where clauses are added one by one to the query and then the query is executed last
  • This is a good case for building into a scope
  • The range parameters could be passed as variables to control how many days ahead to look
  • The technique could be varied using Carbon to do things like birthdays this week

Snapey left a reply on Form Model Binding Related Many To Many Models • 2 days ago

Not sure why you need to copy $tag->id to a separate variable? Why cannot the in_array use $tag->id ?

Also, often overlooked (the docs don't call this out), `old() accepts two attributes. The first is the old form input, the second is the default value which can be the model attribute. old() will use any previous form input and if that is not available, then the default value.

does this help? (my code tends to be a trial and error, but cannot do that here)

@if(isset(old('tag[$tag->id]',$training->tags[$tag->id] ?? null)

    checked=checked

@endif

The ?? is a php7 thing to protect against tags being null

Snapey left a reply on Form Model Binding Related Many To Many Models • 2 days ago

regarding using the same form for both, this is my preferred approach now, but before that I used a partial for the form fields and the main view just contained the method specific form open tag

now I initialise a new model and then call the edit function.

Suppose this was crud for Task object;

 public function create(Request $request)
{
    $task = new Task();

    return $this->edit($task, $request);
}

public function edit(Task $task, Request $request)
{
    $task->load('related','models');

    $categories = Category::all();

    return view('task.edit')
                ->withTask($task)
                ->withCategories($categories)
}

I don't find this ugly as I have dried up my code quite a bit.

in the view, I use @if($task->exists) in order to decide which form open tag to use and if sending to the store or update methods.

The rest of the form is written identically for either create or update.

22nd April, 2017

Snapey left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 3 days ago

If you have it in the $dates array then when you do this->dob then it is converted to Carbon instance before your function receives dob.

If you want the raw value then use $this->attributes['dob'];

but, this seems redundant if you have already have it as a Carbon instance.

Just use @mikefolsom suggestion.

Snapey left a reply on Artisan Migrate Output (comment/info) • 3 days ago

The output became more verbose in 5.4.16

https://github.com/laravel/framework/pull/18379

Snapey left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 3 days ago

Have you already cast this to a carbon instance in the $dates array?

Are you sure it does not have time attributes also?

If you dd($this->dob) at the start of this function, what do you get?

btw, this is redundant

        if($bd->isBirthday(Carbon::today())) {
            return true;
        } else {
            return false;
        }// end if

You can just return the result of the test

    return $bd->isBirthday(Carbon::today())

Snapey left a reply on How To Call The Controller In Laravel? • 3 days ago

You need to create a route in web.php to the controller method you want to respond.

eg

'Route::get('/soulfy', [email protected]');'

Snapey left a reply on Cant Access Attributes • 3 days ago

but the error is that there is no date_birth column?

are you sure of the spelling?

Edit Your Profile
Update

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