Snapey

at Novate / Microlise

Hire Me

Experience

618,635

952 Best Reply Awards

  • Member Since 3 Years Ago
  • 835 Lessons Completed
  • 1 Favorite

23rd September, 2017

Snapey left a reply on Error On Click Of Submit Button In Form • 4 hours ago

When posting code, please use three backticks ``` before and after your code blocks.

https://help.github.com/articles/github-flavored-markdown

Snapey left a reply on Error On Click Of Submit Button In Form • 6 hours ago

can't help without code

22nd September, 2017

Snapey left a reply on Order Inside Eloquent Select? Order In Relation • 16 hours ago

Eloquent can't really help you here... you need to use a join

(example only)

App\Airport::join('cities','airports.city_code','=','cities.code')->orderBy('cities.country')->paginate(10);

Snapey left a reply on Password Resets Bring Me To A Situation Where Users Cannot More Login • 17 hours ago

here

 $response = $broker->reset($credentials, function ($user, $password) {
                $this->resetPassword($user, $password);
        });

where does $password come from?

Snapey left a reply on Overwrite Default Notification • 17 hours ago

could be in the login form? The href pointing to the password reset needs changing ?

21st September, 2017

Snapey left a reply on Where In Array • 1 day ago

boy! I hope you are not still struggling 6 months on. ;-) Can't see any of these answers improving on what I suggested...

Snapey left a reply on Splitting My Data In Half • 1 day ago

I don't know blueimp

maybe this can help from @PovilasKorop

http://laraveldaily.com/upload-multiple-files-laravel-5-4/

Please mark answered if you can now split your data.

Snapey left a reply on How Do I Return A View? • 2 days ago

Is this a trick question?

Do you un-comment the last line, and comment out the line above it ?

Snapey left a reply on Splitting My Data In Half • 2 days ago

Its perhaps more appropriate to do this in the view

@foreach( $menu->nth(2) as $item)

    //list out items

@endforeach

@foreach($menu->nth(2, 1) as $item)

    //list out items

@endforeach

20th September, 2017

Snapey left a reply on Duplicate Queries Using @include In Blade • 3 days ago

You need to review the actual queries to understand what is wrong, and what is being repeated needlessly

Snapey left a reply on Duplicate Queries Using @include In Blade • 3 days ago

Without relevant code its impossible to say

19th September, 2017

Snapey left a reply on Uploading Large Dimension Files • 3 days ago

more likely an out of memory issue when resizing

Snapey left a reply on Uploading Large Dimension Files • 3 days ago

OK, when you look at the error logs, it will start the stack trace and the last line in the log will be the top of the stack trace

You need to back track from the bottom of the file to the point where the error is thrown.

The lines will count down as you scroll up. The above is line #46 on the stack trace

Snapey left a reply on Uploading Large Dimension Files • 3 days ago

So we are looking for something like PostTooLargeException in Illuminate/Foundation/Http/Middleware/ValidatePostSize.php ?

Snapey left a reply on Uploading Large Dimension Files • 3 days ago

ok. How do you know the files are uploaded?

As far as I can see, you have not identified the exact error?

Snapey left a reply on Get A Warning On Dashboard When There's Any Reset Password Mail Sent. • 3 days ago

Is there a mail out waiting to be handled..

being queued you mean? Why would the email not be sent immediately?

and another one when Laravel either prune it due to expiration

The password reset is not 'pruned' it has a 'created_at' column and can be checked for age if the token is used. Otherwise it just sits there.

or deleted

Does not appear to be deleted. I still have some waiting in the table for resets performed yesterday.

Snapey left a reply on Laravel Notification: Is It Similar To Webhooks? • 4 days ago

You will probably need to use events rather than notifications and then implement calling the other server with an http library like guzzle

http://docs.guzzlephp.org/en/stable/

Adam Wathan has a package that wraps guzzle in a more fluent interface

https://laravel-news.com/zttp-guzzle-wrapper

Snapey left a reply on Error 500 • 4 days ago

use three backticks ``` before and after your code blocks so we can see what you are on about

Snapey left a reply on MODEL->save() Error • 4 days ago

@thomaskim I don't really get the pattern but I think he is storing multiple document types in one table, and using another table to store the names of the columns that have to be updated for any given document

18th September, 2017

Snapey left a reply on MODEL->save() Error • 4 days ago

I'm guessing this is returning 0

It possibly also ought to return an array?

    public function getAttributes() {
        return DocumentsAttribute::where('document_id', $this->id)->orderBy("id")->get();
    }

Snapey left a reply on Get A Warning On Dashboard When There's Any Reset Password Mail Sent. • 4 days ago

ResetsPasswords throws an event when a password is reset

event(new PasswordReset($user));

// instance of Illuminate\Auth\Events\PasswordReset;

You should be able to just hook a listener into that?

Snapey left a reply on Undefinded Index After Renaming/refactoring • 4 days ago

visibility in your Storage::put should be 'public' or 'private'

Did you search and replace 'public' for 'frontend' at some point?

Snapey left a reply on Uploading Large Dimension Files • 4 days ago

When you look in the logs, the most recent error is at the bottom.

Simples!

Snapey left a reply on Laravel 5.4 How To Use $request->old • 4 days ago

@mauroavello

most people find this easier;

<input id="name" type="text" class="form-control" name="name" value="{{ old('name',$user->name ?? '') }}" required autofocus>

Snapey left a reply on Only The Second AND Condition Is Executing Not Executing The First AND Condition In If Statement • 5 days ago

There are several problems. Test each query individually so that you know what it does.

If you specify multiple wheres in one then you put them also in an array, not just an array for each condition

However, I think its easier to read with multiple where;

if(($csid === DB::table('posts)
    ->where('type',$type)
    ->where('admin_id',$id)
    ->pluck('id'))

but actually you need to check your logic since in the question you imply that the second query should only run if the first is false

&& will firstly execute the first query. Then if that answer (comparing to $csid) is true then it will run the second query, and only if that is true will the message be displayed.

condition 1 AND condition 2 must both be true

Also, condition 2 is not performing any comparator so the true/false is just based on whether the query returns anything.

I think you probably just need one query with an orWhere within

17th September, 2017

Snapey left a reply on Auth::login Returns An Error • 5 days ago

¯_(ツ)_/¯

Snapey left a reply on 4 Tables Relationship? • 5 days ago

you can use sync() in place of detach and attach

please remember to mark it solved if you are happy with the solution

Snapey left a reply on Nested Eager Loading Could Not Load Information. • 6 days ago

$experiences = Giftbox::with(['experiences', 'experiences.company'])->find($id)

You get the GiftBox with experiences and company, but then you discard all that by

->experiences()->get();

which just gets all experiences associated with gift box

Just a small change should do what you want..

$experiences = Giftbox::with('experiences.company')->find($id)->experiences;

Snapey left a reply on Uploading Large Dimension Files • 6 days ago

I get a 500 error.

You could do just a little work and identify the reason for the 500 error. You know, like the exact error and the class/line number

Snapey left a reply on 4 Tables Relationship? • 6 days ago

Ok, so if we understand the situation;

Question has many Answer, Answer belongs to just one question

User has many Answer, Answer has many User

Because User and Answer is many to many, a pivot table is required and this should be called answers_users to stick with convention

I would link question via answer, and remove it from the pivot to make it cleaner;

(note table name change)

Schema::create('answers_users', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('user_id')->unsigned()->index();
    $table->integer('answer_id')->unsigned()->nullable();
    $table->timestamps();

    $table->foreign('user_id')
          ->references('id')
          ->on('users')
          ->onDelete('cascade');
        
    $table->foreign('answer_id')
          ->references('id')
          ->on('answers')
          ->onDelete('cascade');
});

relationships;

class User extends Authenticatable
{
    public function answers()
    {
        return $this->belongsToMany('App\Answer');
    }
}

class Question extends Model
{
    public function answers()
    {
        return $this->hasMany('App\Answer');
    }

}

class Answer extends Model
{
    public function question()
    {
        return $this->belongsTo('App\Question');
    }

    public function users()
    {
        return $this->belongsToMany('App\User');
    }
}

when you want to list out all questions with possible answers;

$questions = Question::with('answers')->get();

when you want to list all users that chose a specific answer

$answers = Answer::with('users','question')->find(5);

when you want to find all of a user's answers

$answers = $user->answers->with('question')->get();

when you want to find all answers to a specific question, and who gave that answer;

$answers = Question::with('answers.users')->find(1);

(or if you know the question)

$question->load('answers.users');

hope this helps?

16th September, 2017

Snapey left a reply on View Without Data Control • 6 days ago

you should eager load the user as well as characters

in your view, you can lose the @if by using or or the null coalesce operator ?? in php 7

i can't really fathom what you are doing in that loop and running where filter in the loop so can't really advise further

Snapey left a reply on Doubt In Running Php Artisan Route:list • 6 days ago

you need to review the use of this. Did you know that this and other server variables are available through the Request object?

anyway, that aside, you have a problem with your use of this because artisan commands boot the framework and DO NOT create a request_uri because artisan is not a http request

I think if you switch to request you will have better luck

Snapey left a reply on Uploading Large Dimension Files • 6 days ago

you also need to consider the max post size

Snapey left a reply on Not Able To Deploy Laravel On Shared Hosting Getting Internal Server Error • 6 days ago

possibly an error writing the laravel log file. Check your permissions for the storage/logs, and also try deleting the log file to see if one is created

Snapey left a reply on Nginx | Can Only Access Some Routes But Not All • 6 days ago

what about the laravel log file?

Snapey left a reply on Php Artisan: Use Of Undefined Constant FT_UID - Assumed 'FT_UID' • 1 week ago

it you get an error in an artisan command, it's not obvious where that might be. Artisan is using your project itself to run so any errors should be dumped into the laravel log file

it sounds like a config value, and maybe is throwing an error because you don't have it in your .env file so it's using the value from the config php file

Snapey left a reply on How To Show Form Error Feedback Of Input That `type='file'`? • 1 week ago

the type of input should be irrelevant. you are just inserting a div if $errors contains a certain field name

dump($errors) somewhere in your view so you can be sure you are passing an error related to photo into the view

Snapey left a reply on Best Approach To Share Info Between Users In My App • 1 week ago

I would create a Barter model

This would be like a pivot, but you can manage it in its own right since you have to

  • check if an existing barter already exists
  • create a new row when either initiate
  • record acceptance status of both (assuming it can go either way?)
  • have an expiry date (or work off difference from created_at
  • understand the state of the barter easily

Snapey left a reply on For Many-to-Many Relationship - Why Is There No Integrity Violation When Timestamps Are Missing? • 1 week ago

Perhaps your database version allows nullable columns without complaining?

Later versions of mysql complain if you don't provide a default value or make the column nullable

15th September, 2017

Snapey left a reply on Is There A Way To Get A List Of The Migrated Classes After Migrations Takes Place? • 1 week ago

you would probably need to intercept the migrate command somehow

Snapey left a reply on Object Not Found Other Than The Root Directory "/" • 1 week ago

most likely it us because you don't have the document root set to the laravel public folder

if root is not correct, whether your route starts with a backslash makes a difference

Snapey left a reply on Is There A Way To Get A List Of The Migrated Classes After Migrations Takes Place? • 1 week ago

Put your code in the migration. it's just a php script.

Snapey left a reply on Nginx | Can Only Access Some Routes But Not All • 1 week ago

something must happen? an error? what?

Snapey left a reply on Is There A Way To Get A List Of The Migrated Classes After Migrations Takes Place? • 1 week ago

Migrations create or maintain database tables.

Therefore, i'm confused what you are asking about?

Snapey left a reply on Laravel How To Send Email On New User Registration Only To Admin Email • 1 week ago

You cannot put additional code after the return statement

      protected function create(array $data)
{
    $user = User::create([
        'companyname' => $data['companyname'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
        'VAT' => $data['VAT'],
        'companyphone' => $data['companyphone'],
        'companystreet' => $data['companystreet'],
        'companycity' => $data['companycity'],
        'companycountry' => $data['companycountry'],
        'companypostcode' => $data['companypostcode']
        
    ]);
    

    //you can include $user in your email now

    Mail::send('newUser', function($message){
        $message->from('[email protected]');
        $message->subject('welcome');
        $message->to('[email protected]');
    });

    return $user;
}

Snapey left a reply on How To Pass The Array Value Into Raw Query? • 1 week ago

(Select sb.* from sb_item_code sb where sb.stock_date='.$dateOption.' AND sb.period ='.$scOption.'

never concatenate user input into sql strings

(It was made illegal and punishable by public humiliation in 2007)

Snapey left a reply on Auth::login Returns An Error • 1 week ago

Try

$user = User::where('username', $username)->where('activation_code', $activation_code)->firstOrFail();
$user->update([
    'status' => 1,
    'confirmed' => 1
    ]);

    auth()->login($user);
}

Snapey left a reply on Auth::login Returns An Error • 1 week ago

actually scrub that, you are trying to run a query against a user instance

Edit Your Profile
Update

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