shez1983

Experience

46,465

41 Best Reply Awards

  • Member Since 2 Years Ago
  • 163 Lessons Completed
  • 1 Favorite

21st January, 2018

shez1983 left a reply on Is There Any Way To Enable CSS Suggestions Inside ".php" Files In VS Code • 17 hours ago

you could for now just use an external .css file nd reference that?

shez1983 left a reply on Get An Item From A Collection With Percent Rate • 1 day ago

i m still not sure what you are asking so if random_int returns

30? 70?

what do you want to happen

shez1983 left a reply on Calling Save() Method Doesn't Output Anything In Tinker. • 1 day ago

have u looked in the DATABASE?

shez1983 left a reply on Set Default Value For User • 1 day ago

not sure what u mean by this When i use DB::table('habits') the app know that I mean happ->'habits' table?

nd why are u not using eloquent

shez1983 left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::withTimestamps() • 1 day ago

i also have a feeling you are doing this wrong -

you only need 2 models not three.. category & projects

and in each u need a belong to many called projects (not category projects) and you dont need a hasONE.. do read the docs

shez1983 left a reply on Hello MRS, Is There Anyway To Secure Form Inputs In Paypal From Change By Inspect • 1 day ago

hm.. you cant prevent a field from being changed BUT with paypal once user gets to the checkout stage, and clicks pay you store their basket etc in the db - send them to paypal and then after they are paid paypal sends them back (or pings a url on your side with transaction info) - you can then check if what they paid was what was on their basket...

i am not sure if paypal payment have changed/added more methods since I used it few years back..

(I would also use stripe/braintree where you charge the user from the backend)

shez1983 left a reply on How Can I Pass LocalStorage Data To Database ? • 1 day ago

how do the guest select products? clicking a button / link? if so you could fire an ajax request as well as saving it to the db..

20th January, 2018

shez1983 left a reply on Always Redirect To Single Route After Login • 1 day ago

i think this is a good user experience - why would you want them to go to home if they wanted to go to reports?

19th January, 2018

shez1983 left a reply on Git Workflow Question • 2 days ago

tbf it doesnt matter which host you use - they are all fine.. I dont think they allow you unlimited users/projects on free plans though - so you need to look at features/price of each and then go accordingly.

The one good thing about gitlab as has been pointed out is that you can install it on your own machine ie your own private server..

shez1983 left a reply on New Application With 100's Of Form Fields • 2 days ago

what kind of forms are they?

is the data fixed or can you add more fields in the future? (if static, i would go for col based approach, thats easy, if not then i would go for

forms = id, form_name etc,
fields = id, form_id, name, etc
valus = id,  value
field_value = id, field_id, value_id
users_data id, user_id,  field_id, answer... 

shez1983 left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 2 days ago

can you turn of refreshDatabase and see what happens then? can you also install valet or test this on a server to see if you get same results there?

shez1983 left a reply on Global Exception Handler? • 2 days ago

you can look out for the exception that Laravel throws, catch it in the app/exception.php and redirect back.. basically you need an if in the render/report function in that file..

16th January, 2018

shez1983 left a reply on Any CRUD Generator In Laravel? Im Sick Of Copy The Same Shit • 5 days ago

@sashah please feel free to create one - no one is stopping you..

shez1983 left a reply on Trait Adds Creating Event, How To Extend Same Event In Model • 6 days ago

maybe dont use that trait for this particular model and create a new one? -

also if you plan on using this with ALL your models then why dont you have a function boot in the baseModel which every model extends from that way you might be able to do something like you put up..

shez1983 left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 6 days ago

could it be something you are doing in TEstCASE that is run for evey test? that spikes up teh usage/RAM and thus slowing down the test? but then again the stats you showed didnt indicate Laravel/phpunit using more RAM..

shez1983 left a reply on "whereHas" And "with" In Eloquent • 6 days ago

if you are doing the check on whereHas() then no need to do another check in with since it will give you only those results which satisfy the whereHas() conditions

15th January, 2018

shez1983 left a reply on Laravel S3 'exists' Method Always Returns False • 6 days ago

so then there is your problem - you are not storing your files where you think you are... so the problem is not exist.. show us your code where you are storing your files..

shez1983 left a reply on Query For Users With Rating • 6 days ago

->with('rating')

is causing a problem - it expects a relationship NOT an int..

all you need to do is replace rating with reviews.. then do $user->rating... (in the foreach) should work

shez1983 left a reply on Shared Hostling - Error When Trying Insert Something To Database • 6 days ago

how much are you paying for shared hosting? i bet something like 60$ (or similar) - for this you can get your own VPS on digitalOcean..

shez1983 left a reply on Laravel S3 'exists' Method Always Returns False • 6 days ago

and can you get the contents? $exists = Storage::disk('s3')->get($path); just for testing dump them out

shez1983 left a reply on Laravel 5.5 - Is Debugbar Working After Login For Anyone? • 6 days ago

i have installed debugbar in laravel 5+ projects and it seemed to be working for me. only if you have an ERROR in your code causing early termination..

14th January, 2018

shez1983 left a reply on Error : Cannot Use 'in' Operator To Search For 'length' In • 1 week ago

in? i dont see you use in in that code?

did you console log this out? JSON.parse(response);

shez1983 left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 1 week ago

what if you re-arranged the tests so the first few happen afterwards? or run that test on its own to see how long it takes in isolation?

i know pretty stupid suggestions but it is truly baffling..

ONe other trick that i always do now is have a mysql testing db - which is seeded and in my tests i use TransactionTrait so each test DOES run in isolation... without having to refresh db in each test..

shez1983 left a reply on Queues On Forge • 1 week ago

i think the answer to your 'fourth' question is answered by yourself

nd have had it occasionally freeze on me which I haven't been able to get the the bottom of

shez1983 left a reply on InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 1 week ago

if your UserFactory is inside factories folder then that is all good..

& u dont need to change..

ArticleTest should extend testcase (its a class inside tests folder) which extends PHPUnit_Framework_TestCase

12th January, 2018

shez1983 left a reply on Those Five Little Words ... • 1 week ago

too much choice is not freedom... i was being funny cuz of how you started the thread :p

shez1983 left a reply on Those Five Little Words ... • 1 week ago

really???? :'(

11th January, 2018

shez1983 left a reply on Laravel Or Lumen To Use With React ? • 1 week ago

you can move your project to use full blown laravel at a later stage -

if performance is an issue then probably neither - use something else (node, python etc)..

if pure api then lumen.. otherwise laravel... (if you need to do more stuff like queues/events etc)

shez1983 left a reply on Event Listener To Store Points For A User, DB Issue • 1 week ago

whats you q?

10th January, 2018

shez1983 left a reply on Increment Value When A Button Is Triggered • 1 week ago

if you want just that button (or selected) buttons then do it in the controller like you have done..

an alternative would be to use javascript to send an ajax call..

shez1983 left a reply on Files Protection • 1 week ago

ideally you will need to create a fake route with param of the file the user have stored (ideally that name should be coming from db)

that route will then look for that in storage and give access to it..

  1. you could force download of the file (pdf)
  2. you could show the file (if image)

shez1983 left a reply on Is It Possible To Pass Variables Like This • 1 week ago

the problem isnt laravel the problem is lack of 'development' or 'coding' sense - you would make the same mistake regardless of framework...

9th January, 2018

shez1983 left a reply on Database/Eloquent - Db Design? • 1 week ago

no its not morphable.. because each page can have multiple layouts.. (I suppose naming is a bit off here, should be called sections) so a page Homepage can have different sections..

and those entity_id/type tells you what each section is.. ie 'about category', 'about seller etc'

anyway I have sort of hacked it.. so I am creating a row called entity_id = 0, type=category, view=list.. and then in controller inject the products in it...

seems to be working..

shez1983 started a new conversation Database/Eloquent - Db Design? • 1 week ago

In my current app - i have categories table, products table etc so user can do /categories/1/products to get products of a ctaegory..

In the new version we want to be able to allow admins to change layout of the page so i need to do something like:

data { 
    'layout' => { /.... }
    'items' => {...}

the problem is this functionality needs to be on other pages (homepage, sellers pages etc)..

so as a first stab i did:

layouts:  id,  title, entity_id, entity_type, rows, size, view..  
layout_items: id, title, image, price

Now this works for homepage because admins will have multiple layouts for homepage.. one could be a banner, another could be a scroll for products.. (entity_id, entity_type reflects this)

Problem? well i dont know how to fit this into my categories or seller pages?

shez1983 left a reply on Account And Subaccounts - How To Flatten To One Collection • 1 week ago

the relationship returns a collection - so could you not use flatten on the collection by first merging all collections together?

alternatively you could turn them into arrays, merge and then use laravel's built in array_flatten() to flatten array..

shez1983 left a reply on Execute Code After Successful Validation In A Form Request, • 1 week ago

you can MODIFY the form request class.. for example you can do something like:

       if (isset($this->request->get('sale')['enabled']))
        {
            $rules['sale.price']      = 'required|integer';
            $rules['sale.start_date'] = 'required|integer';
            $rules['sale.end_date']   = 'required|integer';
        }

shez1983 left a reply on File_put_contents(C:\xampp\htdocs\xxx\storage\framework/sessions/KXcxw0bXfbUEyvf2fCN12hiHt9VFeWTFFEzS42rk): Failed To Open Stream: No Such File Or Directory • 1 week ago

have you hardcoded the paths somewhere? usually laravel should just use correct values..

shez1983 left a reply on Form Request Validation • 1 week ago

just a fyi form request validation DOESNT work with LUMEN if you are using that.. if not then you have to share your code.. my crystal ball doesnt seem to be working today.. ;)

8th January, 2018

shez1983 left a reply on Group Collection SUM By YEAR • 1 week ago

nop it isnt..

@cmdobueno in most cases it will be faster for SQL to do the sort than for you to fetch all the records and then sort in your app.. with 100 records you may not see a huge difference but there will always be a difference...

@burlresearch sure the OP said collection but usually when people answer they also try to give 'better' (or alternative) solution

shez1983 left a reply on Upload Laravel Project To CPanel • 1 week ago

what are you trying to do that you get that error?

it happens because u need to do php artisan make: if you just do php artisan make - that will give u that error

shez1983 left a reply on Which Course To Choose? • 1 week ago

you can start with vue2.. i believe.. it should go through same basic stuff as before afaik.. and some things have changed anyway

shez1983 left a reply on Group Collection SUM By YEAR • 1 week ago

it is better (For performance reasons) to do it in SQL then to do it in the PHP afterwards..

shez1983 left a reply on How To Check If User Is Logging In With Other Ip Address Laravel 5.5 • 2 weeks ago

if you want user to login once only - then what you can do (and this is not fool proof, nor is it correct as you may get complaints from users using dynamic IP, which is almost everyone)

just store their IP address you can get it from $_REQUEST or laravels $request.. just store that in the users table and check for that when users log in to make sure IP is the same..

shez1983 left a reply on Can't Get Foreign Id Name With Group By • 2 weeks ago

$key is not an object - like you say its an ID...

shez1983 left a reply on Counting Different Types In A Column • 2 weeks ago

assuming ur table is something like

id, type

you can do

select count(type) from table 
group by type

shez1983 started a new conversation Digital Ocean - Loadbalancers Automatic SSL • 2 weeks ago

So I want to try to set up loadbalancers in DO instead of forge (One benefit, before anyone asks is that its a flat 20$ for however much traffic, otherwise we have to get a normal server & provision it in Forge as a load balancer).. are there any downsides to this?

But my Question was that following a DO guide to set up a SSL - it seems wont be an automatic task.. I would need to do it every few months again if I want to use LetsEncrypt.. anyway to automate this? DO's guide mention we should probably do it but not HOW..

7th January, 2018

shez1983 left a reply on Group Results By Year • 2 weeks ago

you can do somethin like

Contest::with('attainments')
                                -> orderBy('name')
->groupBy('year')
                                -> get();

this would give u rows like:

2013, 'www',
2013,'ddd',

you can also leave your original query - then do collect($contests)->groupBy('year')

shez1983 left a reply on Auth::attempt Not Checking If Password Is Correct, But Checking Email • 2 weeks ago

@snapey regardless of this - the attempt() shouldnt pass because it specifically checks password.. :s

6th January, 2018

shez1983 left a reply on Looping Through Values In_array And Checking Multiple Checkboxes • 2 weeks ago

and can you do the same var dump for $grade_array i did a quick test and for me it worked.. so there must be something wrong.. i would also try: (just for test) hard coding $grades_array see what happens and then hard code the other $list_of_grades and see what happens..

shez1983 left a reply on Need Help With Eloquent Relationship Problem • 2 weeks ago

your requirements do not fit polymorphsim structure.. in polymorphsim all three tables are related yet your requirements say otherwise.. you need to change your requirements

Edit Your Profile
Update

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