shez1983

shez1983

London

Member Since 3 Years Ago

Experience Points 84,585
Experience
Level
Lessons Completed 223
Lessons
Completed
Best Reply Awards 80
Best Answer
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.

15 Nov
12 hours ago

shez1983 started a new conversation One Controller Or Duplicate N Times?

So in my app i currently recreate the same controller depending on User or if its a JSON request so i could have in my COntroller folder:

Admin\UserController; Client\UserController; Resource\UserController;

initially i thought if it was one controller each function would be doing too much - i would have to constantly check which user it is and restrict etc...

But i am not so sure.. sometimes i think this looks messy :s

shez1983 left a reply on Retrieve Model With Where Conditions

I am not sure how 'fast/efficient' this will be but you could do:

// get all tickets
// then:
$tickets->groupBy(function ($item, $key) {
    return $item->status !== 99;
});

then you will get two groups..

14 Nov
1 day ago

shez1983 left a reply on Retrieve Model With Where Conditions

orderBy('ticket_status', 'ASC') should not give you all new tickets.. did you even try this? it will give you tickets ordered by status -

shez1983 left a reply on How To Write Test Case For All Routes?

well short of paying someone to do your work - you will have to build tests for each - ideally you should have been doing TDD approach - almost always people have less motivation to add tests afterwards..

13 Nov
2 days ago

shez1983 left a reply on Dusk Unexpectedly Accessing Two Databases In Same Test

i used it with homestead iirc (last year) not using it currently

12 Nov
3 days ago

shez1983 left a reply on Strange Behavior On Event Trigger And Listener

first of all can you move the add food to a repository/service class and then call that from both controllers..

2nd: add dumps() (or use xdebug?) to figure out whats happening.. it is quite strange

shez1983 left a reply on Dusk Unexpectedly Accessing Two Databases In Same Test

was there a q in your last post? :p BTW dusk does something silly it copies your .env to .env.testing and in my past experience this can fail or something, cant remember exactly

shez1983 left a reply on Show Delete Action Only If Check Passes On The Model

i was watching NOVA laracast videos and i believe he does mention a way to limit it - sorry cant remember the syntax.. (you can use a policy and that will work so in it check whatever condition should be and return true/false)

shez1983 started a new conversation Policies/Gates For Custom Things?

so i like the whole syntax @can().. but i wondered if i could do a custom one? ie if i have some logic:

     // show pay now button
}

or should i just create a helper func instead of attempting to use policies :s

11 Nov
4 days ago

shez1983 left a reply on All Problems With The New Laracasts Design

also my watch laters could be renamed to something better.. Queue/play list etc.. :s

shez1983 left a reply on Schema - Dynamic Prefix On Primary Key

yes there is no need to do that - you can query that info and show the branches in each city..

shez1983 left a reply on MySQL Logs To Papertrail On Forge

i am not sure if this will work but you could create a cronjob (laravel command) that would take the mysql log and then for each line just do \Log::info(''') so your laravel will echo it to papertrail

shez1983 left a reply on Post Edit Form - Old Values Not Appearing (Using L5.7; BS4.1)

cronix is right - for file uploads what people usually do is just show the file (thumbnail or name) above/side/below the input file box. with a Delete button so user can delete and also add another file

shez1983 left a reply on Many To Many Ordeal

  1. you need to check something like $user->relationship()->whereRelationshipId($request->id)->exists()..

  2. i think thats the best approach. get all relationship ids and when you are displaying categories do a check if their id is in the ids..

shez1983 left a reply on Is There Any Way That I Can Speed Up The Ffmpeg Processing Time

correct me if i am wrong but your last fileUpload controller code, you are passing filename, you need to STORE it first on your server/s3 wherever and then give the path or name to the JOB.

2ndly when the job runs, your app doesnt get a notification ie in your browser that the job is finished, if you want to do that you will need to use JS/sockets etc

10 Nov
5 days ago

shez1983 left a reply on Best Approach To Handle Third Party API Responses

i agree. you would want to create an adapter or wrapper so every call to the 3rd party is wrapped with how you want the data to be displayed.. also you can then add caching on this wrapper..

shez1983 left a reply on Name Attribute Exhausting PHP Memory

if on the course you have protected with = course, and in deposit you have protected with = deposit then it creates a circular loop where laravel tries to include course in deposit and then deposit in course and so on..

shez1983 left a reply on Laravel Queue On Production Not Working

thne you need to add dumps() to see at what point it stop working.. so add dumps on whatever is being queued (emails, jobs, commands)

09 Nov
6 days ago

shez1983 left a reply on Factory Not Retrieving DB Records Properly

well at this stage when you create a cluster factory, i am assuming there isnt any rows in the database. how are you using this factory?

for factories i just create new instances of whatever vm1 or vm2 are.. something like:

return factory(App\VirtualMachine::class)->create()->id,
},

then in my seeder i will actually do that while loop if i need to add records..

shez1983 left a reply on What Are The Best Practices For Use Of Laravel Commands Vs Jobs

for your specific case it looks like you should use command.

i agree with what you said ie Jobs tied to a controller/service & command are standalone

08 Nov
1 week ago

shez1983 left a reply on Please Bring Back The Older Laracasts Design

at laast i can see (finally) the notifications bell after the revamp

shez1983 left a reply on Please Bring Back The Older Laracasts Design

@POVILASKOROP - technically he isnt wrong on either counts..

shez1983 left a reply on Please Bring Back The Older Laracasts Design

apparently there is (was) a course on TDD on laracasts. Jeffery may need to take a refresher (re: timezone issue) :p

shez1983 left a reply on Please Bring Back The Older Laracasts Design

@JEFFREYWAY - hey one more problem on firefox when i try to view my profile e.g. https://laracasts.com/@shez1983. i can see something for a sec and then the page goes blank. i dont get any errors in inspect. BUT when reloading if i immediately press escape to stop the execution of script i see the page..

shez1983 left a reply on Laravel Queue On Production Not Working

try doing just php artisan queue:listen and see what happens

shez1983 left a reply on Core PHP Vs Laravel

i think you are comparing cake to eggs/flour.. with laravel you get something that is done and with PHP you have to create everything yourself (or add in all the packages if you are into composer and then learn/read on how to use those packages)

05 Nov
1 week ago

shez1983 left a reply on Disable Sql_mode On Forge For A Particular Application

next time i will spoon feed you @matthiascw the answer.. even better write the whole project for you! getting quite irritating this..

shez1983 left a reply on How To Store Laravel Session In Local Storage Or Web Storage

well to store in local storage, you would need the help of JS. laravel i dont think can do this for you.

whats wrong with the good old session/cookies to store cart data?

04 Nov
1 week ago

shez1983 left a reply on How To Store Data In Session For The Next Page Request?

really you generate the cart array, how is doing one line of session()->put('name', json_encode($array)); problematic :s

shez1983 left a reply on How To Store Data In Session For The Next Page Request?

you can store session 'until the next request'... reflash() is a similar thing.. it puts things into session for one time use only iirc.. what i suggest is you mimic what reflash() does.. and get rid of session data on the next request/when needed.. :s

shez1983 left a reply on Add User_id To A Guarded Model

if its not in the fillable you can always do it manually

$model->user_id = '';
$model->save();

shez1983 left a reply on What Is A Good Solution For One Time Payments?

@D9705996 you say that but in the introduction of cashier it explicitly states

f you're only performing "one-off" charges and do not offer subscriptions, you should not use Cashier. Instead, use the Stripe and Braintree SDKs directly.

03 Nov
1 week ago

shez1983 left a reply on How To Store Data In Session For The Next Page Request?

quick way is to just store the array cart in your own session when user is in /cart page and then delete it when user goes to the appropriate page - this is a basic php concept..

cookies can be used as well..

shez1983 left a reply on Page Has Expired Due To Inactivity

you need to post your code then. are you doing ajax or a simple submit form?

02 Nov
1 week ago

shez1983 left a reply on User Fields Seem Empty When The User Is Has Been Registered

isnt this: array $data wrong? you are supposed to be using Request $request and then doing $request->input('name')....

shez1983 left a reply on How To Run Laravel Project Locally Without Using "php Aritsan Serve" Command?

have you tried valet or homestead? not sure why built in php isnt working for you though.. try looking at the SOURCE of the page when css dont load and see where the path is linked to..

shez1983 left a reply on "Include" One Function Into Another In Controller?

if its a controller function.. then its not that easy.. the fact that it appears in TWO places is a code smell...

in any case i would refactor to create a class (repository/service) and then call it from both location..

shez1983 left a reply on Searching Two Tables Using Laravel And AJAX

@Cronix @winiciuslima I was going to say the same thing - how selfish.. i wish there was a way to block a user so i dont have to help them again if they do this..

01 Nov
2 weeks ago

shez1983 left a reply on Disable Sql_mode On Forge For A Particular Application

is this a setting in config/database where you can disable/enable strict mode.

shez1983 left a reply on How To Monitor Status On Dependent Api Systems

two options:

  1. when your app is using these services do try/catch and in catch LOG those errors (and use slack/email notification system in laravel to send you an alert)

  2. more easy one is to use (or create a service) that regularly pings these services and gets a 200.. theres one called uptime robot or something..

but more to the point - if those services are having issues theres nothing you will be able to do even if you get errors.. hint* use queues so that 'email' is not lost and you can retry once service is up

shez1983 left a reply on Laravel Cashier Issues When Setting Up Subscription With Declined Credit Card

in a normal stripe you are supposed to use Stripe JS library to create a card - which if accepted returns you a card object, from which you just need to pass token to your backend - here you create a customer in stripe associating that card token to the customer which gets you a stripe_id for the user which u store in your backend...

with Cashier its similar flow.. (i will check at work but i have used cashier for subscription but cant remember what the JS library returns in that case.. )

shez1983 left a reply on Use The Same Route For Internal Application (i'm Using React) And An Arbitrary External API

well technically if you are building an api then you shouldnt use 'web' even for react - you should pretend react is just another dumb external app that is using your API.. so it needs to do whatever passport requires it to do..

but to ans you q: one thing i would try is middleware('auth:api'); should really be:

middleware(['auth:api', 'web']); and see if that works..

shez1983 left a reply on User Can Create Tags And Can Follow Tags... Best Strategy?

well you would have to use TWO relationship func anyway... whne a user create tags they own them.. and it would be a straight user_id in tags table.. when a user follows tags, it would be a many to many so a pivot table will be created..

think of two names to identify these relationships and stick with that..

my gut instinct tells me: tagsOwned() tagsFollowed().. to make that distinction.. else you could call one just tags() but that would be ambiguous down the line..

shez1983 left a reply on How Do I Indicate On The Route That I Am Passing Two Parameters To The Controller?

Route::get('/payment/{product, rate}', '[email protected]');

what on earth are you trying to do? i suspect you rather want something like this:

Route::get('/payment/', '[email protected]'); and then call it like:

url.com/payment?product=id&rate=20

however to satisfy YOUR question (which i dont think laravel can do by default) you can hack it

Route::get('/payment/{productRate}', '[email protected]');

    $params = explode(',' ,$param); // just make sure when you pass in productRate to the route you have Comma separated param.. 

}```

shez1983 left a reply on Searching Two Tables Using Laravel And AJAX

and what part of [2018-11-01 20:03:30] production.ERROR: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous is confusing you? did you actually try to READ what this says..

29 Oct
2 weeks ago

shez1983 left a reply on Can't Delete Items From Cart, Only Quantity And Leaving The Item With 0 Quantity

i am not sure what you are doing... so making some assumptions here:

each order = an item in the cart.. qty relates to how many of an item user wants.

function() {

$newQty = $request->qty;

if ($newQty == 0) {
 $order->delete();
} else {
  $order->qty = $newQty; 
  $order->save();
}

this is all i think you need.. i am not sure why you are complicating stuff.. :s

the only other thing i would do is check my product stock which you are not currently doing either.. to make sure they dont enter 100 as qty when you only have 20 stock

shez1983 left a reply on Pass Data To Form On Another Page

so i assume in your script you send that to store() which then redirects to prescriptions?

if so then in script when you redirect to prescription you can add a session variable, or a URL param.. and then check for those in ur presc form and add a hidden field..

shez1983 left a reply on What Part Of The Application Should Be Responsible For Executing Caching?

it should be that script that you have wrapped around your external API that should be responsible for caching.

28 Oct
2 weeks ago

shez1983 left a reply on Can't Delete Items From Cart, Only Quantity And Leaving The Item With 0 Quantity

i suggest write english (ie comments on exactly what needs to happen in every case of qty.. and then write the code line by line)...

27 Oct
2 weeks ago

shez1983 left a reply on Dusk Unexpectedly Accessing Two Databases In Same Test

i think this makes sense because your test at that point is VIEWING your site as if you would.. and when you do, your data doesnt end up in the test db rather in prod db.. you are not supposed to use dusk for production.. only your local/staging.. and for that i think this is fine..