dmcglone27

Experience

43,390

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 417 Lessons Completed
  • 6 Favorites

11th February, 2018

dmcglone27 left a reply on Factory()->create() Error.... I'm Having All Kids Of Bumps In The Road These Past Couple Days. • 4 months ago

Thanks @tykus , I forgot the user in my factory, but for some reason I also had to quit tinker and start it again for it to work correctly.

dmcglone27 left a reply on Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

Ok. when using raw html, the form submission does return to the form upon success and also on failure, but on failure it doesn't retain the old data and it doesn't show the error and looks as if the form was submitted.

dmcglone27 left a reply on Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

Ok I'll run the form through a couple paces using the raw tags so I can try and explain.

dmcglone27 started a new conversation Factory()->create() Error.... I'm Having All Kids Of Bumps In The Road These Past Couple Days. • 4 months ago

I am following Jeff's build a forum laracast and when I try to use the factory method in tinker to create the 50 posts, I end up with this:

factory('App\Thread', 50)->create() PHP Notice: Undefined offset: 0 in /www/forum/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 488

dmcglone27 left a reply on Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

@Snapey This is tough to explain. Ok let me try something. First let me ask how can I add the #contact to a laravel collective form? I looked at Laravel docs, but can't find anything.

convert this:

<form action="{!! route('contact') !!}/#contact" method="post" />

to this:

 {!! Form::open(array('route' => 'contact',  'class' => 'form')) !!}

dmcglone27 left a reply on Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

I'll just post all the pages here:

My form. Reverted to plain html for the time being.

    @if (count($errors) > 0)
                            <div class="alert alert-danger">
                            @foreach ($errors->all() as $error)
                                    {{ $error }}
                                @endforeach
                            </div>
                        @endif

<form action="{!! route('contact') !!}/#contact" method="post" />
  
<input id="name" type="text" class="form-control" name="name" value="{!!  old('name') !!}" required>
  
 <input type="submit" 'Submit'>
  

My controller:

public function ContactForm(ContactFormRequest $request)
    {
        $data = [
        'name' => $request->get('name'),
      
];
        Mail::send('emails.contact', $data, function($message) use ($data)
        {
            $message->from($data['email'], $data['name']);
            $message->to('[email protected]', 'David')->subject('mailtrap Inquiry');

        });

            return redirect('http://alta/contact' . '#contact');

    }

My form request. Added the Max attribute to force a fail:

 public function rules()
    {
        return [
            'name' => 'required | max:3',
        ];
    }

dmcglone27 left a reply on Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

@Snapey If I did it correctly, Yes.

{!! Form::text('name', old('name'), ['class' => 'form-control', 'required' => 'required', 'placeholder' => 'Your Name']) !!}

dmcglone27 left a reply on Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

Thanks @Snapey, this method does return back to the form, but it clears the form and it doesn't show any errors. Hmmm

10th February, 2018

dmcglone27 started a new conversation Returning Back To An Anchor Tag When There Are Errors In A Form • 4 months ago

Hi guys, how do I return back to an anchor tag when there are errors in a form?

I am able to return back after a successful form submission, but when there are errors, it returns to the top of the page. Here's the code I'm currently using.

In view

@if (count($errors) > 0)
   <div class="alert alert-danger">
     @foreach ($errors->all() as $error)
        {{ $error }}
     @endforeach
  </div>
@endif 

Controller

 return redirect('http://alta/contact' . '#contact');

1st November, 2017

dmcglone27 left a reply on Link Anchors Don't Work • 7 months ago

I figured this out.. For some reason bootstrap.min.js was causing it. No idea why.

31st October, 2017

dmcglone27 started a new conversation Link Anchors Don't Work • 7 months ago

I have a menu that uses anchors which point to various sections of the welcome page, and everything works just fine, until I am on a stand alone page. I can't for the life of me figure out why the links will not work.

my nav

<li><a href="/#meetings">Meetings</a></li>
<li><a href="/#events">Events</a></li>
<li><a href="/gallery">Gallery</a></li>
<li><a href="/#newsletter">Newsletter</a></li>

Every link works fine until I am on the gallery page, then the links will not work at all. I'm at a total loss.

If I put the menu code directly into the gallery page, it doesn't work that way either.

26th October, 2017

dmcglone27 left a reply on SSL On 5.0 • 7 months ago

@Cronix Thanks again, it was a link to a weather widget.

dmcglone27 left a reply on SSL On 5.0 • 7 months ago

@Cronix that was it.. It's something in my app.blade.php.. I haven't found what it is yet, but I suspect the javascript.

dmcglone27 left a reply on SSL On 5.0 • 7 months ago

Hmmm I'll check my code.

dmcglone27 left a reply on SSL On 5.0 • 7 months ago

I just uploaded an index.html file to the 5.0 website and the SSL works, so that confirms it is the Laravel installation. Does anyone know what could be causing it?

dmcglone27 started a new conversation SSL On 5.0 • 7 months ago

I just set up SSL on a 5.0 and a 5.2 Laravel installation, and on the 5.2 installation everything works just perfectly, but on the 5.0 installation the https URL works, but it still says it's not secure. Is this a problem with my Laravel or should I suspect the installed certificate?

18th October, 2017

dmcglone27 left a reply on Ordering Dates • 8 months ago

Thanks guys, after a long hiatus from Laravel, I forgot a few things, but seeing the examples , refreshed my memory and here is what worked for me.

view()->composer('partials.events', function ($view) {


            $view->with('events', Events::orderBy('date')->where('date', '>=', Carbon::today())->where('archived', false)->limit(3)->get());

        });

17th October, 2017

dmcglone27 started a new conversation Ordering Dates • 8 months ago

Hi all, I'm trying to get 3 dates, but I don't want any date that is more than 2 or 3 days in the past. For example I have Sept 29, 2016, Oct 15, 2017, Oct 16, 2017 and Oct 31, 2017.. All I want is the 15th, 16th and 31st of 2017 what could I do here to accomplish that? I have tried latest(), latest('date', 'asc') but neither work. Suggestions?

view()->composer('partials.events', function ($view) {

            $view->with('events', Events::orderBy('date)->where('archived', false)->limit(3)->get());

1st June, 2017

dmcglone27 left a reply on Is Using .env Or .htaccess On Server Good Or Bad • 1 year ago

I'm sorry, it's /home/username. It's the folder up one level of www or public_html on the server.

dmcglone27 left a reply on Is Using .env Or .htaccess On Server Good Or Bad • 1 year ago

@Snapey I see. So my best bet would be to move .env out of the www folder and into / correct?

@jlrdw I tested this earlier and my app properly displays the 404 error page and not the .env file.

dmcglone27 left a reply on Is Using .env Or .htaccess On Server Good Or Bad • 1 year ago

That appears to be for subdomains. my dir structure is

-www all the Laravel files and folders .htaccess .env .git .gitignore etc...

Should I be putting .htaccess, .env or both in / instead of www?

dmcglone27 left a reply on Is Using .env Or .htaccess On Server Good Or Bad • 1 year ago

Thanks. I was doubting it because of a recent hack and somehow my .htaccess was removed.

dmcglone27 started a new conversation Is Using .env Or .htaccess On Server Good Or Bad • 1 year ago

When uploading a project to a shared server, should I leave the .env file where it is or should it not be used?

8th February, 2017

dmcglone27 left a reply on Getting Date From Db In Different Format • 1 year ago

@mstnorris Yeah I tried that, and then my view would complain it couldn't find ->diffForHumans() etc etc..

But then again I've been at this for about a day, so everything was just jumbled up. But the options @cviv suggested worked perfectly. :-)

dmcglone27 left a reply on Getting Date From Db In Different Format • 1 year ago

Ah Thank you! Worked perfectly. I couldn't find these timepicker options on the web.

Thanks @cviv

dmcglone27 started a new conversation Getting Date From Db In Different Format • 1 year ago

I'm using the bootstrap datepicker, to insert a date into the db, but in order to use carbon, so I convert the date before inserting it into the db using

        $input['date'] = Carbon::createFromFormat('m/d/Y', $request->date)->format('Y-m-d');

My problem is when I go to the edit page, my date field cannot be populated, because the date is a carbon instance, so I'm trying to convert it back to m/d/Y format for editing. here's my form

                {!! Form::text('date', $meetings->date, array('class' => 'form-control', 'input-group date', 'id' => 'datetimepicker', 'required' => 'required')) !!}

I've tried using several ideas

 $meetings->date->format('Y-m-d')
 format('Y-m-d', $meetings->date)

And several other ways.

So how can I get the date in the correct format to populate the field?

3rd January, 2017

dmcglone27 started a new conversation Multiple Social Login And Regular Login • 1 year ago

I've added Socialite to my login page and the default behavior is to only allow the user to consistently log in with the initial method they chose.

So I'm wondering if it's bad or good to allow the user to log in using any method after signing in with a different method they previously chose?

For example a user logs in using facebook then comes back to the site later and forgets they logged in with facebook and tries to log in using google but it will not allow them to log in because their google email is the same as their facebook email and they can't log in using the form provided either.

In my case, if the user forgets, they are left with 4 different guesses, did I log in with fb? did I log in with google? did I log in with linkedin? or did I use the provided form?

How could this scenario be handled?

28th December, 2016

dmcglone27 left a reply on Refactoring • 1 year ago

Yeah It is a simple example, but you answered my question with the perfect answer.. "move them to a helper class". Now I've got something to focus on and practice.

Thanks :-)

Hopefully others will drop a suggestion as well with various other methods if there are any.

dmcglone27 left a reply on Refactoring • 1 year ago

Post verification is like a Nazi here... lol

dmcglone27 started a new conversation Refactoring • 1 year ago

I'm trying to get better at refactoring so I took a simple read directory script and put it directly into my index controller. Now I'm trying to figure out a method to refactor so I can remove the code from the controller and keep it clean. What are my options with Laravel? What method of refactoring would everybody suggest? Here's a quick snip of code I copied from php.net and altered a little for this exercise. Also, this code example doesn't work, I'm just using it as a visual example. With that said, what method should I use to extract this code and clean up my controller?

~~ public function index()

$files = opendir("/"); while (($file = readdir($files)) !== false) { if( ! is_dir($file) && $file != "." && $file != '..' && $file[0] != '.' ) { return the results; } } } ~~

18th December, 2016

dmcglone27 left a reply on Errors • 1 year ago

@clay Ah, that was it!! My routes were not in the middleware group!

Thanks a bunch man!

dmcglone27 left a reply on Errors • 1 year ago

You mean when it fails on submission and returns back?

dmcglone27 left a reply on Errors • 1 year ago

I'm using a request. I've even tried putting the code directly into my view like this

@if (count($errors) > 0) Please correct the following errors:

@endif --

dmcglone27 started a new conversation Errors • 1 year ago

Hey all, I'm trying to figure out why I have access to the errors variable in one project but not the other. I can't recall what I had done in the working project for it to work. Am I missing a package?

The error I get is: Undefined variable: errors

It works with version 5.2.43, but not 5.2.45

Here's the code: http://pastebin.com/M6RYUGK8

30th September, 2016

dmcglone27 left a reply on What Changed In The New Laravel That Effected Update? • 1 year ago

I have solved my mystery.. here's what happened

I started with this:

{!! Form::text('task', $task->taskName) !!}
{!! Form::text('task', $task->description) !!}

Then @rsands brought DB row names to my attention so I fixed it with this:

{!! Form::text('task', $task->taskName) !!}
{!! Form::text('description', $task->description) !!}

Then I realized the description was working, but not the task. Thought I must have missed my fillable field so I checked, but that wasn't it. The problem turns out my row name was wrong it should've been taskName not task.. Grrrrrrrr how did I miss that for so many hours?

{!! Form::text('taskName', $task->taskName) !!}
{!! Form::text('description', $task->description) !!}

Even though this made me look like a complete idiot, I appreciate the help you guys threw my way. I'm probably the only one who makes these type of idiotic mistakes.

dmcglone27 left a reply on What Changed In The New Laravel That Effected Update? • 1 year ago

@Eddie212 When he brought that to my attention, I fixed it, but got the same result, but I think it was just the chain of events that happened that made the first attempt fail, So I agree that was probably the problem all along.

dmcglone27 left a reply on What Changed In The New Laravel That Effected Update? • 1 year ago

Ok I just read everyone's suggestions and went through my code and tried the suggestions, but I was getting the same behavior, so I decided to use a plain html form instead of using Laravel collective and that didn't go well. So I put everything back the way I had it and the damn thing started working..

So I compared my code to what I posted above and there's no difference whatsoever. Now I'm even more intrigued to what happened..

dmcglone27 left a reply on What Changed In The New Laravel That Effected Update? • 1 year ago

No error, it just redirects back with no changes.

29th September, 2016

dmcglone27 started a new conversation What Changed In The New Laravel That Effected Update? • 1 year ago

I'm trying to update a record like I always have and it's doesn't working. I've looked in all my previous projects, and anywhere I can think of for an answer, but for the life of me can't get update to work.

Here's what I got

My form

   {!! Form::model('tasks', ['method' => 'PATCH', 'action' => ['[email protected]', $task->id]]) !!}
         {!! Form::text('task', $task->taskName) !!}
        {!! Form::text('task', $task->description) !!}
        {!! Form::submit('Update') !!}
        {!! Form::close() !!}

Controller

 public function update(Request $request, $id)
    {
        $task = Task::findOrFail($id);
        $task->update($request->all());
        return redirect()->back();
    }

Model


    protected $table = 'tasks';

    protected $fillable = [
        'taskName',
        'description',
        'completed'

This is just simple stuff, but what in the world is going on?

24th September, 2016

dmcglone27 left a reply on Routes In 5.3.10 • 1 year ago

@InaniELHoussain I have that exact route. but if I don't add this route

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

The index page doesn't work unless I specifically use http://......../tasks

23rd September, 2016

dmcglone27 left a reply on Routes In 5.3.10 • 1 year ago

insert, update and delete work now. good thing I asked, because I was about to ditch Route::resource all together.

dmcglone27 left a reply on Routes In 5.3.10 • 1 year ago

@snapey @InaniELHoussain Ok gotcha. I just made a separate route for /. I misunderstood all that.

dmcglone27 left a reply on Routes In 5.3.10 • 1 year ago

If I do it that way, then / won't work :-/

dmcglone27 started a new conversation Routes In 5.3.10 • 1 year ago

Following Jeff's series on a task app, I started a new project with the new laravel and Route::resource isn't working, i get "page not found" when I visit either the edit page or the show page for individual items, but when I add my own routes it works fine. Is this me or did something change?

Here's my routes file

Route::resource('/', 'TaskController');

I tried:

public function edit($id)
    {
        dd('hello');        
    }

even tried:

public function edit($id)
    {
            $task = Task::findOrFail($id);
            return view('edit', compact('task'));
    }

but if I change my routes to this everything works!

Route::get('edit/{id}', '[email protected]');
Route::get('show/{id}', '[email protected]');

7th September, 2016

dmcglone27 left a reply on Frustrated • 1 year ago

+jekinney Thank you. I think the next thing I need to take a look at in depth is request, to understand it better.

6th September, 2016

dmcglone27 left a reply on Frustrated • 1 year ago

Does it look to you if I'm even doing it correctly?

dmcglone27 left a reply on Frustrated • 1 year ago

I tried save() as well and I get an error

FatalThrowableError in AlbumController.php line 129: Call to a member function save() on string

dmcglone27 started a new conversation Frustrated • 1 year ago

I have no clue why the image name is not being saved correctly. I've tried everything I can find and think of and it just keeps saving it as something like /tmp/398983... It's frustrating not being able to figure out what's going wrong.

This is my update method

public function update(Request $request, $id)
    {
        $album = Album::findOrFail($id);
        umask(0);
        File::cleanDirectory('images/cover_photos/' . $id);
        $imageName = $request->file('album_cover')->getClientOriginalName();
        $request->file('album_cover')->move('images/cover_photos/' . $id, $imageName, 0777);
        $album->update($request->all());
        return redirect()->back();
    }

dmcglone27 started a new conversation GetClientOriginalName Entering Tmp Name In Db • 1 year ago

Hey all, I'm trying to upload an image and enter it's name into the db and everything works well except instead of entering the file name into the db it's putting the /tmp/bla.png into the db when I want the name of the file. I can't figure out why this is doing this. Can anyone see what Is going wrong here? Here's my controller: public function update(Request $request, $id) { $album = Album::findOrFail($id); umask(0); File::cleanDirectory('images/cover_photos/' . $id); $imageName = $request->file('album_cover')->getClientOriginalName(); $request->file('album_cover')->move('images/cover_photos/' . $id, $imageName, 0777); $album->update($request->all()); return redirect()->back(); }

9th August, 2016

dmcglone27 left a reply on Faker Class • 1 year ago

Ah Ok. I was only using this in my Model

protected $fillable = ['body'];

Changing it to this works

protected $table = 'about';

protected $fillable = ['body'];

Thank you very much. :-)

Edit Your Profile
Update

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