shez1983

shez1983

Member Since 4 Years Ago

London

Experience Points
99,235
Total
Experience

765 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
226
Lessons
Completed
Best Reply Awards
98
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 20
99,235 XP
Nov
18
1 day ago
Activity icon

Replied to How To Cache A Paginated Query

@sinnbeck that will not work...

you need to add to the key page you are on so

Cache::get('myAwesomeComments' . $request->get('page', 1), function...

page is laravels default get param it uses for pagination

otherwise no matter what you do (ie go to next page - you will get same results

Nov
16
3 days ago
Activity icon

Replied to One Custom Request Class For Both Create And Update Action

i personally would keep things simple and not use data [] wrapper (but i take it its coming from API?)

in the FormRequest validation you can have something like:

$rules = ['name' => 'required']....

if request()->isMethod('patch') or if request()->has('data') 

// array_map and append 'data.' to each rule key.. 
Nov
12
1 week ago
Activity icon

Replied to Trying To Get Property 'important_body' Of Non-object

i think your signature is wrong:

function show(Article $article , $id)

$article is already loaded if you have route model binding.. $id is superflous... if you dd ($article) you will see

Activity icon

Replied to Login Function Doesn't Validate

to answer your q.. its the else part where u need to do a header to go back to login form..

} else {
                    $password_error = "<p>Password is not correct!</p>";

you might want to get a hard hat - because people are really going to criticise your code.. this is to put it bluntly horrible... something from 90s.. or early 2000s..

Activity icon

Replied to Unlimited Number Of Optional Parameters In Route Uri

may i suggest using get params instead? url.com?param1=ddd&param2=ddd etc.. more cleaner - of course if its not needed as i dont know what u r doing stick with what u have but it can bite you in the backside as this route might be triggered for other scenarios..

Nov
11
1 week ago
Activity icon

Replied to Is It A Good Thing To Have Many Textarea ?

yeah thats clear - thats acceptable.

Activity icon

Replied to Searching For Hints/tips For Making Website Work On Smartphones.

why are you spamming this forum and bringing up dead posts? you are alienating people here

Activity icon

Replied to Check If Endpoint Exists

sometimes you need to make the endpoints for your android/ios guys.. if so then a mock response should be sent as that will show you and them what is needed.. ie great for planning

Activity icon

Replied to Is It A Good Thing To Have Many Textarea ?

from program wise i dont think its a problem - for humans to fill that many text areas (well i dont know how many you have) might be a detriment - esp if required, could make users leave your site.. (ie if used for registration)

Activity icon

Replied to Loop Inside A Loop. Continue At The Index+1 Where The Intern Loop Stop

yes you will have to but at the moment your F/E is doing unnecessaery work of filtering out. also you shouldnt be using DB:: thats what eloquent/relationship is there for (albeit they work for simplistic) even if you do it using JOIN etc it should still work.. for dates u just have to parse them as carbon instances first..

Nov
07
1 week ago
Activity icon

Replied to Factories With Closure

can you give an example of scope how it should look like? can you also tell us what this factory is doing now and any errors you may be getting? you can also do the json_encode when you return the scope instead of doing it outside (not sure if that would make much difference) can you also take the return [ ] of the Userfactory (not including return). and in tinker create an array and see what value scope has

Nov
06
1 week ago
Activity icon

Replied to Loop Inside A Loop. Continue At The Index+1 Where The Intern Loop Stop

i am not actually sure of what your answer is - but some of the logic can be done in controller or even in the sql query - you are getting all appointments and then checking if appoint not today.. similary the second if can also beommitted but i am not sure what it is doing..

Nov
05
2 weeks ago
Activity icon

Replied to Error: Unexpected '@endforeach' In Blade

you can also look at the compiled version of blade (which is pure php) sometimes to see what its doing..

Activity icon

Replied to Laracasts Improvements Discussion

@jlrdw its ironic you are questioning his programming experience ;)

Nov
04
2 weeks ago
Activity icon

Replied to Laracasts Improvements Discussion

i dont think anyone would sit here and 'mark complete' all videos to have a higher XP - it gives them no incentive/bonus/award or indeed even a pat in the back...

Nov
03
2 weeks ago
Activity icon

Replied to @guest @elseguest Part Not Working?

it doesnt matter what version i am using - i clearly gave u a snippet from the core with Else compiling function.. which means i should have access to elseauth elseguest

i am on 6.0 but that wont make a difference..

Activity icon

Replied to Laravel Illuminate\Support\Collection - FirstOrNew (and Similar) Possible With Extending? (Not Eloquent)

you can extend collections if that is what you are asking.. there are some instructions in the docs..

Nov
02
2 weeks ago
Activity icon

Replied to @guest @elseguest Part Not Working?

@nakov please see my first post again....

Activity icon

Started a new Conversation @guest @elseguest Part Not Working?

so i was doing something like:

   // do something
@elseguest
  // do somethinge else
@endguest

but elseguest doesnt 'work'.. if i change the whole thing to use @auth @elseauth @endauth.. elseauth doesnt work.. but i can see

/**
     * Compile the else-guest statements into valid PHP.
     *
     * @param  string|null  $guard
     * @return string
     */
    protected function compileElseGuest($guard = null)
    {
        $guard = is_null($guard) ? '()' : $guard;

        return "<?php elseif(auth()->guard{$guard}->guest()): ?>";
    }

phpstorm is registering @elseguest

for now i have just done @auth .... @endauth @guest ... @endguest

Activity icon

Replied to New Package Development

lets not get on the high horse - i didnt mean to sound condascending! i rarely post 'look at the docs' - the only reason i said in this case is because of

include __DIR__.'/routes/api.php'; part this is not how the doc states we should load routes theres a dedicated loadroutes() or similar function it uses!

i hope u got it out of your chest and feel much better!

Nov
01
2 weeks ago
Activity icon

Replied to New Package Development

if you look at the docs for package development it tells you how to get your routes/views/ etc 'seen' by laravel.

Oct
28
3 weeks ago
Activity icon

Replied to How Do I Sort And Group Tasks By Complete Status

yes it needs to be a boolean! @kkatwork

Oct
23
3 weeks ago
Activity icon

Replied to How To Design A Specific Situation..

i dont know if that makes sense. what i would do is have a product -> has many prices table.. and this would have store_id, product_id, price.

then you can have an accessor/helper func on product to get the price relating to the store..

Oct
21
4 weeks ago
Activity icon

Replied to Application Performance Monitoring

network tab (inspect element) can tell you how long requests are taking.

debug bar will tell you a bit more incl which queries are taking longest (which u can use to determine which funcs are taking longer)

Oct
19
1 month ago
Activity icon

Replied to UpdateOrCreate Error

there are two ways i would approach this.

  1. Create an SQL query yourself for example: https://stackoverflow.com/questions/3432/multiple-updates-in-mysql. and then run it once..

  2. use event/listener/job to queue this job for the background so it doesnt affect the users.

https://laracasts.com/discuss/channels/eloquent/performant-way-to-mass-update-or-create

Activity icon

Replied to Better Solution For SQL Query

it seems to be theres a relationship between voo/na.. so you can utilise laravels relationship to only SELECT rows which are matching - you are getting all the voo and na and then in php disregarding the ones that dont have a matching comparison.

the other thing is ofcourse pagination - you should only get 15 or so results at a time..

third solution would be caching.

you can do all three in combination with each other

Oct
14
1 month ago
Activity icon

Replied to How T Check Is Param Collection Or Object

ok so what i think you should do is move the $users out of the func. only pass in EITHER a USER or multiple users not both..

i would prefer a single user being passed in. then outside the func where its called u will/should know if u have one user or more.

Alternatively do what laravel does.. always pass in array.. even if its one check inside the send() and create an array and then just do the loop..

Oct
12
1 month ago
Activity icon

Replied to Php Artisan Migrate Class Not Found

what do the lumen doc state? I know lumen has some of the laravel functionality stripped off to make it lightweight/faster etc..

also if you have phpstorm or a good editor try fining Migrate classes (or just browsing via vendor/ folder to see if you actually have them).

Oct
10
1 month ago
Activity icon

Replied to Order By Not Working

in your group by clause you need to put all other columns as well...

so groupBy('company', 'col1', 'col2') its a SQL 'problem' not a laravel one.

Activity icon

Replied to Create A New Primary Column In Production

when you say three columns do you mean as a sort of unit? ie something like primary(['col1, col2. col3']

Activity icon

Replied to How To Call A Method Where FormRequest Is Required?

if you feel like u have to call another method like that - you need to extract that functionality to a different class.

Action pattern (create an action called for example AddUser($data) and then call it from wherver that action is required)

Repository pattern - would need to search too much to explain but follows similar to above..

or just extract the functionality to a class..

Activity icon

Replied to Lumen RealTime

what i think you need to be searching for is API - since you are using lumen i think you need to create get/post routes to do whatever users can do via your app and then connect the endpoints.

you can do socket stuff but might be too advanced/not worth the hassle.. depends on your needs as well. its only really applicable if you need some sort of interactive experience (like an instant notification or chat etc)

Oct
06
1 month ago
Activity icon

Replied to How Do You Standardize Your JSON Responses?

you can use API Resources. but if you are not returning a model, then sometimes i will create a helper function (In the base controller), you can do this anyway you want, i.e. have one for error () where u pass in the error, one for success where u pass in an optional entity/message... that way all your json responses will be defined in one place/consistent

Activity icon

Replied to Cannot Make New Laravel Application

one peculiar thing i noticed is how your path uses \ but also has a / C:\Users\corbi\AppData\Roaming\Composer\vendor\composer/../symfony/polyfill-ctype/bootstrap.php

how is your composer.json looking in this project?

you could try is to go to that location C:\Users\corbi\AppData\Roaming\Composer\ and delete vendor folder.

Oct
05
1 month ago
Activity icon

Replied to Stripe Testing (Subscriptions Etc)

@sti3bas thanks for that. - i get you shouldnt mock what you own.. but i think if u use mocks in your unit and then still test actual stripe connection in your integration tests which u only run once while uploading to your repo or your server etc i dont see what the problem is? at least thast what i have been led to believe. this way everything ADAM said in that link is applicable - i.e. stripe changes your integration tests will catch that..

Activity icon

Started a new Conversation Stripe Testing (Subscriptions Etc)

is there a guide on how to write tests for stripe (mocking it etc).. i have been googling but still a bit unsure?

I am using latest Laravel 6.0. creating a subscription when user registers. i am mocking the create() function of Stripe\Customer which is used to create customer. but regardless of mocking it is still being called?

public function test_i_can_register()
    {
        // arrange

        $this->mock(\Stripe\Customer::class, function ($mock) {
            $mock->shouldReceive('create')->andReturn(json_decode(example Request))
        });

this is what i am hoping to mock

www/vendor/stripe/stripe-php/lib/ApiOperations/Create.php

    public static function create($params = null, $options = null)
    {
        dump('come here');
        self::_validateParams($params);
        $url = static::classUrl();

        list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
        $obj->setLastResponse($response);
        return $obj;
    }

when i run my tests i can see the dump(come here).. so i know its not working :/

NOTE example request is just one i made and have pasted in there (eventually will be placed elsewhere)

array:26 [
  "id" => "cus_Fw9m3r1gzGagVj"
  "object" => "customer"
  "account_balance" => 0
  "address" => null
  "balance" => 0
  "created" => 1570298062
  "currency" => null
  "default_source" => null
  "delinquent" => false
  "description" => null
  "discount" => null
  "email" => "sdummyemail"
  "invoice_prefix" => "9FE4EC3E"
  "invoice_settings" => array:3 [
    "custom_fields" => null
    "default_payment_method" => null
    "footer" => null
  ]
  "livemode" => false
  "metadata" => []
  "name" => null
  "phone" => null
  "preferred_locales" => []
  "shipping" => null
  "sources" => array:5 [
    "object" => "list"
    "data" => []
    "has_more" => false
    "total_count" => 0
    "url" => "/v1/customers/cus_Fw9m3r1gzGagVj/sources"
  ]
  "subscriptions" => array:5 [
    "object" => "list"
    "data" => []
    "has_more" => false
    "total_count" => 0
    "url" => "/v1/customers/cus_Fw9m3r1gzGagVj/subscriptions"
  ]
  "tax_exempt" => "none"
  "tax_ids" => array:5 [
    "object" => "list"
    "data" => []
    "has_more" => false
    "total_count" => 0
    "url" => "/v1/customers/cus_Fw9m3r1gzGagVj/tax_ids"
  ]
  "tax_info" => null
  "tax_info_verification" => null
]
Oct
02
1 month ago
Activity icon

Replied to Local & Staging Server Behaving Differently?

thanks for replying - but its weird that it works on local and not staging?

Oct
01
1 month ago
Activity icon

Started a new Conversation Local & Staging Server Behaving Differently?

I have docker environment so both local/staging are the same versions.

I have an account Settings page where you have blank password fields (one for old, one for new) they are not required so you can change other settings and click save.

On Local this works as expected (I.e. if u click save without changing anything or other settings) it succeeds

On staging this doesnt work as expected (I.e. if u click save without changing anything or other settings) it gives me an error (i.e. gets stuck by the Form Request)

Here is my form request

   'oldPassword' => [
                'nullable',
                'bail',
                'required_with:newPassword',
                new VerifyPassword()
            ],

            'newPassword' => [
                'required_with:oldPassword',
                new PasswordStrength(),
            ],```
Sep
28
1 month ago
Activity icon

Replied to Need Help On A Syntax Please

@snapey i m referring to the unique but ignore current id since i thought thats what he wanted.. he will have to use it (for update) anyway.

Sep
27
1 month ago
Activity icon

Replied to Need Help On A Syntax Please

you need to use array syntax. in laravel docs for validation there is an example under unique validation documentation.

Activity icon

Replied to Designing An API To Mash Up Public And Private Data

that is tricky indeed. you could replicate what youtube does. get each comment with three replies then have a view more or something.. it can get complicated but doable.

in this case you would have two more apis. one to get paginated comments, another to get comments replies (paginated or otherwise)

Activity icon

Replied to Designing An API To Mash Up Public And Private Data

for cache purposes I would have a post/comments api call and a separate one for likes. - you could combine the two but cache wont be that effective because then for one post & its comments.. each USER will have its own cache but if you have two api calls (one to get posts/comments) and one for like.. the first one will be cached for all users..

Returning all comments for a posts is going to cause slowness as u r having to load all comments so that could again be split.. & paginated.

Sep
22
1 month ago
Activity icon

Replied to Increment When Attached

well laravel does provide few solutions:

  1. you can use static boot function and in it look for static::created()where you increment the usage
  2. you could use obeservers
  3. instead of 1 - you could create an event.. you can use $events/dispatches property on the model to fire an event when user is saved and then create a listener to do what u want (all examples can be found in eloquent section of docs)

but some people would argue saving this kind of data when u can calculate it is not right..

Sep
21
1 month ago
Activity icon

Replied to How To Decrypt Hash Password In Laravel

if you have seen the thread then you wouldnt have asked this q. if you really must do encrypt/decrypt then create your own login/reset which does what you want but it will be insecure

Sep
20
1 month ago
Activity icon

Commented on Basic Routing And Views

do we really need these basic tutorials that are the same in every laravel ? surely there could be some sort of sections that could be linked to..

Sep
17
2 months ago
Activity icon

Replied to Calling Other Function In This Same Controller

have you not heard of fill(); function? which would avoid you doing.

secondly your checkGuaranteePeriod can be simplified if you use a mod operator

. return guarantee_period / 12 and no need for all those if lines.. and no need for that function.. although that function feels like it should be in SALE as a helper func.. so you can always get the guarentee period which u might need to calculate again

also dont forget to VALIDATE user input using FormRequest (head to docs or google)

Sep
12
2 months ago
Activity icon

Replied to Updating Credit Card Laravel Cashier

what i think you need to do is either use stripe js for card details (or build one yourself if you dont like their layout) and hook into their js.

either way their js will do the magic (ie get the card detail and give you a token). you send this to your b/e and associate this with the user https://laravel.com/docs/5.8/billing#updating-the-default-payment-method

https://stripe.com/docs/web/setup start here.

Sep
02
2 months ago
Activity icon

Replied to Migration Only Adds First Item Of Array

stop giving rubbish advice please... his original problem has NOTHING to do with relationship - he isnt USING that to insert data.

I suggest you go back and learn laravel and its basics learn what the people are saying check your answer with someone in your team before u post an answer..

otherwise you annoy people and people will just ignore you!

Aug
27
2 months ago
Activity icon

Replied to Issue With Isset And If Statements In Blade File

you can always go back to basic

@if(isset()

@else 

@endif