shez1983

shez1983

Member Since 3 Years Ago

London

Experience Points 93,325
Experience Level 19

1,675 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 91
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.

19 Mar
2 days ago

shez1983 left a reply on Return View('departments.index') VS Return Redirect()->route('departments.index')

normally you do a redirect after a form post - so you can return back with errors/success etc

18 Mar
3 days ago

shez1983 left a reply on Best Solution For App Settings

i like you use DB and in my setting model have one static func where i will pass in the key of thing i want the value from - this func will also take care of caching the key/value

However recently i have just read an article whereby the author loads all settings into config() and then you can use config() like you normall do for other settings (from config/*.php files)

shez1983 left a reply on Way To Secretly Hide Code Within Laravel

with respect @nhayder solution isnt correct - where are you going to set up cron job on YOUR own server? if so you wont be allowed to delete someone elses file as you wont have permission (linux etc) - will you ask THEM to run a cron job on your behalf? if so - then how are you sure they will run the cron job?

I am not sure what the real solution is but i thought i would let you know that is incorrect. of course i may have gotten the wrong end of the stick.

Actually one solution (again this can be circumvented is) you create a URL kind of like laravel does for its login/reset password.. so your will be domain.com/check-licence... you PING this URL frequently and then this will in turn do something (Note: it wont still be able to delete files)

06 Mar
2 weeks ago

shez1983 left a reply on Problem With Adding Image To Product

@ddaniel so pretty much what I said... but thats ok dont mark it as correct.. i mean its not as if i didnt spend my time looking at your problem and trying to help you..

shez1983 left a reply on Creating Foreign Key In Laravel 5.8.2 Failling

@northofdark is that why you maked someone else's answer as correct!

02 Mar
2 weeks ago

shez1983 left a reply on Creating Foreign Key In Laravel 5.8.2 Failling

can you do a -vvv after you run migrations as it usually gives you the SQL that it is trying to run. also just make sure author id and id on users table both have same data type

01 Mar
2 weeks ago

shez1983 left a reply on Laravel Routes

the design looks slick as well..

shez1983 left a reply on Controllers Structure For API And "regular" Routes

i have done this thing by using Option 3 - but now think i may prefer to just have ONE controller rather than multiple - everything in one place.. :/

shez1983 left a reply on Where To Put Logic Code Between Request And View (noob Q)

and if the day field is 3 do you update column 3 of table B? can you tell us what tables a & b are? maybe your design is wrong?

what i would do initially is extract the switch to a funct (private) on that controller named getActionableField() which just determines what field name/column to 'update' then in ur controller you can update that..

26 Feb
3 weeks ago

shez1983 left a reply on Validation : Must Be In Table Columns Names

client? as in api or a form? if form then you define the input names. if api then again you define whats accepted - in both cases use form validation to make sure everything you require exists otherwise throw a 422 exception.. i am not sure where the confusion is?

shez1983 left a reply on Problem With Adding Image To Product

the problem is that you are :

 if($request->hasFile('product_thumbnail')){
            $image = $request->file('product_thumbnail');
            $filename = time().'.'.$image->getClientOriginalName();
            Storage::put($filename, 'images/product_images/');
         }

this stores the file path to somewhere - so you need to then do:

$product->product_thumbnail = "images/product_images/$filename"
$product->save()

the tmp file is the one php creates automatically - which you save to using storage but u never then save that path anywhere..

22 Feb
3 weeks ago

shez1983 left a reply on Relaionships

cnames looks to me like a pivot table so you can say belongsToMany... even if you want to create a MODEL out of it...

shez1983 left a reply on Relaionships

i cant seem to find a fk that relates devices table to the other two?

21 Feb
1 month ago

shez1983 left a reply on Three Way Relationship Or Relationship With A Relationship?

i am a bit lost. i think there are two things i get from your post

  1. shops can do x many services
  2. shops can only do some services on a particular brand

i would go with your suggestion of creating a providesService Model unfortunately.

19 Feb
1 month ago

shez1983 left a reply on Good API Tutorial For Laravel

you dont need good api tutorials for laravel - you just need good resource to learn api development - after that you can create API with laravel as thats not the hard part.

shez1983 left a reply on Laravel Always Using Cache Versions Of Everything

well the whole point of opcache is so that your code is cached so php doesnt have to look at your code - so after each save you have to restart the php process (google for this)-

now on local machine you shouldnt really start opcache (for exactly the problems you encountered)- its more for production server & without knowing which service you use to deploy (if any) or your process its hard to help you if indeed you are having this problem on production.

18 Feb
1 month ago

shez1983 left a reply on How To Solve This? Undefined Offset: 0 (View:)

@snapey no need to snap.. we have all experienced it - OP's problem is that he might be a beginner so doesnt know how to debug/find bugs etc.. do you ask your fellow colleagues everytime something stops working or debug it yourself?

shez1983 left a reply on Request Return Null

can you show us the dd of request? also why do you use reques() when you have a $request being passed in.. it doesnt matter much but for code consistency use $request->file()... imo null means that image_path is null..

17 Feb
1 month ago

shez1983 left a reply on I Can't Get Property Name From BelongsToMany Method

thats just an array syntax, you could do a simple foreach, or implode..

shez1983 left a reply on Who's Running My Queued Jobs On Forge? :-o

can you confirm .env = not sync on production? thats the only reason things could be working even if you think its supposed to be queued.. other then that a bit of code sample or anything more to help us (maybe even git repo etc)

shez1983 left a reply on Storing Music

s3? or google for some music specific uploading site

yeah you could also upload to your DO and use its backup facility..

shez1983 left a reply on Artisan - Dynamic Namespace?

unless you give us a bit more info i am not sure i follow..

if those five objects share some common actions then you could create one command and give it params of the object and what action you want.. (in the command you would use strategy pattern to new up an instance of a class and then do the action,..)

shez1983 left a reply on Add Relationship After Migration

well will everyone have same experience? or will everyone have experience regardless? to me it doesnt make sense to give everyone an experience unless there are different one (kinda like laravels badges)

anyways, what I would do is either create a SEEDER and run that.. or do a stand alone quick function (call it via tinker) - both are fine and not really hackish..

shez1983 left a reply on Get The Latest Changes From Github

normally you do git pull ... :/

shez1983 left a reply on Who's Running My Queued Jobs On Forge? :-o

sorry i am - i didnt realise you wanted them to stop...

do you happen to have any cron jobs set up in forge? that runs laravels schedule that in turn process the job. other than that I am not sure what else could be happening.

15 Feb
1 month ago

shez1983 left a reply on Does Anybody Know The Right Syntax Here ? ;)

so what does that tell you? what steps have you taken?

14 Feb
1 month ago

shez1983 left a reply on How To Save Image As Blob

i have found a neat solution @boldstar which allows you to save the base64 string into the database.. as text (make sure your column is at least medium text type). then you can spit that out in your & it all works! no need for uploads....

shez1983 left a reply on My Index Model Give Me Random Sort

can u show me your migration table for index? if not then do a desc index in your mysql...

i think your ID is string not a number..

shez1983 left a reply on How To Get Back Original File Code After Running Production Command In Laravel Mix

surely if theres an error in your JS - you should get the same error in local..?

13 Feb
1 month ago

shez1983 left a reply on Accessibility On Laracasts

imo volunteer for a site which has a paid model doesnt sound like a good idea - i am sure the revenue is enough for him to hire someone to do it.

shez1983 left a reply on Mysql Connection Problems

if you have a different creds there then obv phpunit/laravel will use them - for kicks try deleting the .env.testing and hopefully then .env settings will be used @

shez1983 left a reply on Mysql Connection Problems

i think your details here are wrong:

DB_CONNECTION=mysql
DB_HOST=masterdatabase
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=dbuser
DB_PASSWORD=dbpass

Only joking..

just for kicks can you copy this to .env.testing and upload it and see if that works?

also if this doesnt solve it - you should for now use sqlite and :memory: as was posted above.. if you do use mysql then you should add a prefix_ so that your tests create test tables and not work with your normal tables

also as an aside if this is production - you shouldnt be running tests on production..

12 Feb
1 month ago

shez1983 left a reply on How To Store Result Of Expensive Request?

but u must be defining it somewhere currently? whether in ur controller, repository, services etc?

in any case on further thought - u shud create a Singleton... so the first time it will do the query but subsequent times when u call it, it will gvie you the result - this result will be saved for one duration of your requst

shez1983 left a reply on How To Store Result Of Expensive Request?

where are you running this expensive query?

in a controller, Eloquent Model etc?

shez1983 left a reply on Correct Many To Many Relation

just because that returns empty collection doesnt mean its incorrect.. i dont believe u need hasManyThrough but obv you have discarded my opinion so continue on...

shez1983 left a reply on Difference Between Local And Public Drivers

well yes local should be used for those kind of things - but really these days people also upload these to external services such as S3..

as to how to get access.. well search around the google.. i dont have a script to hand.. but it goes something like:

$file = get file from local
present it to the user (whether in blade template or as a download)

shez1983 left a reply on Difference Between Local And Public Drivers

anything uploaded to local is not VISIBLE to outside world directly.. you have to write a script that can get to that directory

anything uploaded in public is STILL uploaded to local directory but under public? path - and you need to create a symlink to this folder in your public/ folder so anythin gin this folder is directly visible meaning i can do localhost/public/somefile.php

shez1983 left a reply on Correct Many To Many Relation

i think the correct example is that BOTH one specific user & stock has reservation.. since a reservation requires both things..

users,
stocks,
reservations:  user_id,  stock_id, ....

then you will have

function reserved_stock()  { //relatuonship on User table

return $this->belongsToMany('App\Stock', 'reservations', 'user_id', 'user_id');
}

and a similar one called reserved_by on stock..

shez1983 left a reply on Route [userlogin.login] Not Defined

can u give us your ROUTE file? & any necessary code

shez1983 left a reply on Error 404 When The Routes Are Correct

can you do a php artisan route:list and see what that gives you? it should show you exactly what the route name is and its usually supposed to be PLURAL.. ie documents not document... :/ maybe laravel is doing this magically behind the scenes

11 Feb
1 month ago

shez1983 left a reply on != Or <> Does Not Work In @if

dump out variable just before this line..

shez1983 left a reply on Help With Increment & Decrement On 2 Rows Of Same Model

what is: $c_order_customerId? is this set.. iunless there is an error on 1st line 2nd line WILL run.. you can install debugbar to see the query being executed? or add couple of dumps() after each line to see if its being run.. generally tho i am not sure what you are doing you shouldnt increment/decrement order_count or do it like that.. u can simply do a COUNT on orders table to get the current count

03 Feb
1 month ago

shez1983 left a reply on How To Display Own Category In Own Block With Laravel?

i was giving you side tip - not related to your q but telling you how you can cut down from 5 queries to ONE.. making ur code a bit more faster to run! sorry

shez1983 left a reply on How To Display Own Category In Own Block With Laravel?

i am not sure i understand what you are trying to do BUT You can do one query using $result = ....whereIn('id', [1,2,3,4]) and then $results->groupBy('id').. or a custom group by

01 Feb
1 month ago

shez1983 left a reply on Using UID Column For API Resource Routes Instead Of ID

sure it can - you will have to save that value yourself (by hooking into saved event or in your save controller method etc).. if you mean route model binding then you just need a func in your model to let laravel know (check the doc for func name)

shez1983 left a reply on How Can I Create Am Api From This. With Out It Routing Back To The Login Page

whats 'secure.api' middleware? what does ur routeserviceprovider look like? how are you accessing these routes?

shez1983 left a reply on Failed To Clear Cache. Make Sure You Have The Appropriate Permissions.

what are the permissions for that folder? do ls -al to find out..

31 Jan
1 month ago

shez1983 left a reply on Is There A Case To Keep "_token" As Part Of The Request?

@jlrdw thats the reason i said what i said @billriess elaborated on it -

shez1983 left a reply on What Are The Challenges You Faced To Host You Laravel Application On Shared Hosting ?

i dont see why people r still using shared hosting? DO the cheapest is only $5 which is same as the monthly cost of a shared host..

29 Jan
1 month ago

shez1983 left a reply on Search According To Keys Defined In Laravel Resource Collection

@sarmadindhar even if it was POSSIBLE you wouldnt/shouldnt do it - imagine your PHP script loading 3k rows for you to then FILTER down to what you want.. instead you should filter in the query to get 10/20 rows that you need...

i dont see why it is/would be difficult for you to query first and then pass that collection to Resource..