Snapey

Member Since 4 Years Ago

Mansfield

at Novate / Microlise

Experience Points 1,276,925
Experience Level 50

0 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 1066
Lessons
Completed
Best Reply Awards 1817
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

24 May
21 hours ago

Snapey left a reply on Call To A Member Function Has() On String

have you tried to use $errors in your own code, or are you saving stuff to the session ?

Snapey left a reply on The UPDATE Method Is Not Supported For This Route. Supported Methods: GET, HEAD, PUT, PATCH, DELETE.

Weve had this discussion before. Stop being so impolite, demanding answers.

You have also been told not to use update when you want to save() a model

You accept Order into your controller, so no need to find it again. Your controller cane be reduced to

public function update(Request $request, Order $order)
{
    $order->status = 1;
    $order->save();
}

Snapey left a reply on Issue With Relationship

you need to change your relationships over also.

Snapey left a reply on Issue With Relationship

Shirt belongs to Color

Shirt belongs to size

Therefore shirt needs color_id column and size_id column

there should not be shirt_id on the color and size tables

Snapey left a reply on Laravel 5.8 How Right Get The Authentificated User?

you should not need this at all since you can access the authenticated user from anywhere, and therefore any of their properties.

You just cannot grab the user in the constructor because of the order in which things are initiated

Snapey left a reply on JS And CSS Not Loading - New Install

have you set the public folder as document root on your webserver?

In the browser, network tools, compare the location you are trying to load the files from, and where they are actually located

Snapey left a reply on Call To Undefined Relationship [profile] On Model [App\\User]

your error message is odd because clearly there is a profile() method

Snapey left a reply on Multiple Indexes Slowing Down Query

Also, see this video from Laracon 2018.

https://laracon.net/2018

Scroll down to Jonathan Reinink - he works through an example of improving eloquent queries with indexes.

Also, don't forget to check the impact of writes. Adding more indexes will slow down the save process.

Snapey left a reply on Call To Undefined Relationship [profile] On Model [App\\User]

According to your question

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

is not using User model in Models namespace

Where are your models?

Snapey left a reply on Call To Undefined Relationship [profile] On Model [App\\User]

You have a new user - you cannot load the profile of a new user as profiles_id will be null

try

>>> $user = User::find(1)

choose a user thats populated and has a profile

>>> $user->load('profile')

>>> $user->profile

Snapey left a reply on Call To Undefined Relationship [profile] On Model [App\\User]

same problem for the relationships in the profiles model?

Snapey left a reply on Cannot Display Date

So back to my original observation. You have sent a string (which happens to be a date) to the client but then you are trying to apply date formatting to it. You would need to convert it to a javascript date before you could do that.

Alternatively in your Purchase model;

create a getter and append it to the response

protected $appends = ['formattedDate'];

public getFormattedDateAttribute()
{
    return $this->date->format('Y-m-d\TH:i');
}

assumes you have already told eloquent that date should be cast to Carbon

and then use $('#date').text(data.invoice['formattedDate'])

Snapey left a reply on SelectRaw Returns JSON In Stead Of Object

In context, this makes sense.

If you want a single model then use

$password = \App\Models\Passwords::selectRaw("AES_DECRYPT(password, '$secret') AS password")

->find($id);

With get() you end up with a collection and you then have to pluck the first entry

Other options are;

$password = \App\Models\Passwords::selectRaw("AES_DECRYPT(password, '$secret') AS password")

->where('id',$id)->first();

There are also firstOrFail() or findOrFail() where you want an error to be thrown if the provided id cannot be found

Snapey left a reply on Cannot Display Date

Totally different code now then?

Snapey left a reply on How To Install Sweet Alert In Laravel 5.8

WHY ARE YOU SO ANNOYING

SORT IT OUT FOR YOURSELF

Snapey left a reply on How To Get Selected Option Value And Text In A Modal When Clicked On A Table Row

ask yourself if you are ready for this...

You need to populate the modal from either data elements on the table row, or via an ajax call.

The best approach depends on how many and what type of fields you need to edit compared to the original table row.

https://stackoverflow.com/questions/10626885/passing-data-to-a-bootstrap-modal

Check the answer by "LostInComputer"

Snapey left a reply on How To Install Sweet Alert In Laravel 5.8

NPM and Yarn are both Javascript package managers. You can use either, there is instructions for using NPM instead of yarn

Snapey left a reply on Cannot Display Date

How have you converted the json sent from your controller into a date object?

Snapey left a reply on Serve Multiple Laravel Apps On Localhost With Php Artisan Serve

note that php's server (the thing behind artisan serve) only handles a single connection at once

This means it is unsuitable for testing api between two websites ( if that is why you want it to serve multiple websites at the same time),

23 May
1 day ago

Snapey left a reply on File_get_contents(): Peer Certificate CN

try

{!! file_get_contents(public_path('/assets/img/icons/chevron_down.svg')) !!}

Snapey left a reply on SelectRaw Returns JSON In Stead Of Object

ref encrypting passwords.

worrying that people still think this is acceptable.

Snapey left a reply on Password Reset Form Shows ERROR 404

if starting again, google forxampp set document root

Snapey left a reply on Form's Submit To Add Comment Not Working T

try to not change your original question, otherwise repliesmake no sense to someone trying to help later.

format your code blocks by putting ``` on its own line before and after

Snapey left a reply on Password Reset Form Shows ERROR 404

myApp versus myapp

Also, you should fix your webserver so that public is the 'document root'. You should not see the word public in you urls

Snapey left a reply on INVOICE NUMBER IS NOT INCREMENT

Better approach is to use a purely numeric invoice number and add the letters in the view.

Snapey left a reply on Password Reset Form Shows ERROR 404

What's the FULL URL of the password reset page (where you request a reset) ?

What's the FULL URL of the link in the email?

Snapey left a reply on Password Reset Form Shows ERROR 404

Is it a laravel 404 error message?

Snapey left a reply on File_get_contents(): Peer Certificate CN

if you are in-lining the svg then you just need to get its contents. It does not matter if it is internal or external since everything is running in php at this point.

Where are your svg files located?

Snapey left a reply on Form's Submit To Add Comment Not Working T

Are you willing to share your web.php?

Its really hard to help if you just give brief replies

Snapey left a reply on Password Reset Form Shows ERROR 404

Is the domain on the password reset link exactly the same as when you use the site

Snapey left a reply on Is It Bad Practice To Use Absolute URL In An Anchor Tag?

Also, you don't want to be hardcoding http into your own URLs because you might want to deploy the site on https

Snapey left a reply on Form's Submit To Add Comment Not Working T

do you have a conflicting comments route?

Check web.php for '/comments' ...

Snapey left a reply on File_get_contents(): Peer Certificate CN

Are you trying to inline svg files?

Why use asset? its going to produce a URL rather than just a path

Snapey left a reply on Remove Parameter From Url

What are you on about?

You think its not possible to search in a database?

Snapey left a reply on Add Route Parameter In Router Class

Just pass it to the controller. Make sure you use the same name in the controller function

web.php


Route::get('post/{id}', '[email protected]')

PostController

public function show($id)
{

//do something with id

}

Unless you are not using Laravel - which is what @jlrdw seems to think ;-)

Snapey left a reply on How To Send Sms After Register A User?

oh, and you don't have code in your user model

Snapey left a reply on How To Send Sms After Register A User?

Some of us have lives you know

    return User::create([
        'first_name' => $request->first_name,
        'last_name' => $request->last_name,
        'gender' => $request->gender,
        'mobile' => $request->mobile,
        'address' => $request->address,
        'birth_date' => $request->birth_date,
        'province_id' => $request->province_id,
        'city_id' => $request->city_id,
        'email' => $request->email,
        'password' => bcrypt($request->password)
    ]);

You see that first word return that means execute this code block and return the value. Do not execute any of the now dead code that follows.

If you want to do something with the user then get the return value from create

    $user = User::create([
        'first_name' => $request->first_name,
        'last_name' => $request->last_name,
        'gender' => $request->gender,
        'mobile' => $request->mobile,
        'address' => $request->address,
        'birth_date' => $request->birth_date,
        'province_id' => $request->province_id,
        'city_id' => $request->city_id,
        'email' => $request->email,
        'password' => bcrypt($request->password)
    ]);

and then remove this line;

$sendSms = new User;

and change all instances of $sendSms to $user so that you know what you are dealing with

Why do you set the mobile number again, you already saved it

This is REALLY basic stuff which you should know by now.

Snapey left a reply on Relation Not Working

ahh the old 'not working'

give us a bit more information

install Laravel debug bar and tell us what query the above is generating

Snapey left a reply on Remove Parameter From Url

search is not an eloquent function

Snapey left a reply on Laravel Session Timeout Redirect Users Based On Role.

redirect when they try to access something that they need to be authenticated for?

How do you know what role they have until they login? Do you see the problem?

Snapey left a reply on Relation Not Working

try

    public function title()
    {
        return $this->hasOne('App\Accounts','code','supp_code')
                                ->where('branchid','=',$this->branchid);
    }

Snapey left a reply on Using WhereIn And Comma Separated Values

$terms = explode(',',$post->meta_keywords);

$query = Post::where('category_id','=',$post->category_id)
                    ->where('status','=','PUBLISHED')
                    ->where('id','!=',$post->id)
                    ->where(function($query) use($terms) {
                        foreach($terms as $term) {
                     
                                $query->orWhere('meta_keywords', 'like', "%$term%");
                        };
                    })
                    ->inRandomOrder()
                    ->take(3)
                    ->get();

Snapey left a reply on Using WhereIn And Comma Separated Values

so if you want to find 'wind' in a field containing 'earth, wind, fire' then you will need to use a like search with % on either side

but, it will also find partial matches, so pulling also a row containing 'brass, woodwind, drums'

Once you have your results you can filter more acurately with regex

Snapey left a reply on Laravel Eloquent Filter Product's Attributes

Managed it with raw SQL but not had time to convert it to eloquent

SELECT p.* FROM products p

LEFT JOIN attribute_product ap ON p.id = ap.product_id
 
WHERE (`attribute_id` = 1 AND `value` IN ('4GB','8GB')) OR
      (`attribute_id` = 2 AND `value` IN ('256GB'))

GROUP BY ap.product_id

HAVING COUNT(ap.product_id) = 2;