Tray2

Tray2

Oracle Developer (PL/SQL, Forms & Apex) at Scania CV AB

Member Since 6 Years Ago

Solna

Experience Points
331,920
Total
Experience

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
1449
Lessons
Completed
Best Reply Awards
282
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 50
331,920 XP
Oct
28
2 days ago
Activity icon

Awarded Best Reply on Database Design : Timestamp Column Or Saperate History Table.

I would go with a product_history table where I'd store all the changes made. I would us a table trigger for this so I don't have to handle it with php.

https://www.w3resource.com/mysql/mysql-triggers.php

Oct
27
3 days ago
Activity icon

Replied to Read Bar Code And Return The Value Of Barcode

If you don't use an external barcode reader there really isn't any purpose to create barcodes. When it comes to the browser a normal link should suffice. I see no need for the browser to be able to read the barcodes.

It really doesn't matter if you use a barcode, datamatrix or qr in your case. Datamatrix and qr can contain more information than a regular barcode that is only a string of text represented as bars.

Activity icon

Replied to Read Bar Code And Return The Value Of Barcode

Just so you know that there are a shitload of different encodings to a barcode.

  • code39
  • code128
  • ++ many more

You need to pick one that suits your need.

This package seems to good and easy to use. It only supports a few of the barcodes but for you I'd guess that code128 is good enough.

https://lindell.me/JsBarcode/

Activity icon

Replied to Which Is The Best Html Text Editor For Laravel Livewire

@gitwithravish I think he meant an editor to replace the <textarea> in a html form and not an editor to write code in. :)

Activity icon

Replied to Which Is The Best Html Text Editor For Laravel Livewire

They are pretty much equal since they all have their pros and cons.

Pick one that is free/opensource, easy to configure and suits your needs.

https://alternativeto.net/software/tinymce/?license=free

I've used TinyMCE and CKEditor.

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: HEAD.

Create a virtual host that points to your public directory and it should work fine.

https://ultimatefosters.com/hosting/setup-a-virtual-host-in-windows-with-xampp-server/

Make sure that it points to your public directory.

Oct
26
4 days ago
Activity icon

Awarded Best Reply on Is The Quality Of Image Depends On Resize In Image Intervention?

When you save the image you can set the quality of the image. Not specifying the quality uses 90% of the source quiality.

Define optionally the quality of the image. It is normalized for all file types to a range from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. The default value is 90.

http://image.intervention.io/api/save

Activity icon

Replied to How To Get Each Column Of My DB :: Select Query

Still don't know what you mean, so I can't help you there.

Oct
25
5 days ago
Activity icon

Replied to Invalid Argument Supplied For Foreach()

What happens when you do

dd($newssources);

?

My guess is that you'll get json and not a collection or an array. If it's json you need to decode it before you use it.

https://www.php.net/manual/en/function.json-decode.php

Activity icon

Replied to How To Get Each Column Of My DB :: Select Query

Not sure what you mean by field and column,

To get a column out of the database you do something like this,

SELECT title 
FROM books

That will give you a list of titles

  • The Eye Of The World
  • The Great Hunt
  • The Dragon Reborn

To get all columns from a table you can either specify them one by one or use the asterix wild card

SELECT title, released, pages. blub
FROM books

Is the same as

SELECT *
FROM books

With two tables joined you can do this

SELECT b.*,
              g.*
FROM books b,
            genres g
WHERE b.genre_id = g.id

Or you can use the more modern approach

SELECT b.*,
	      g.* 
FROM books b
JOIN genres g ON b.genre_id = g.id;

Activity icon

Awarded Best Reply on Storing Laravel Snippits Inside A Database.

As a rule of thumb don't store code in your database.

Building a dynamic menu is quite easy.

Create a table for you menu entries

  • id
  • title
  • link (only needed if you deviate from the standard route convention).

Load the entries from the database and pass them to your view.

In your view itterate through the entries

<nav>
@foreach($menuEntries as $entry)
	<a href="{{ $entry->link }}">{{ $entry->title }}</a>
@endforeach
</nav>
Activity icon

Replied to Is The Quality Of Image Depends On Resize In Image Intervention?

When you save the image you can set the quality of the image. Not specifying the quality uses 90% of the source quiality.

Define optionally the quality of the image. It is normalized for all file types to a range from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. The default value is 90.

http://image.intervention.io/api/save

Activity icon

Replied to How To Get Each Column Of My DB :: Select Query

Why not just pass the collection on to the next function?

Activity icon

Replied to Best Practice / Optimize Performance

My guess is that the database isn't hosted on the same server as the http server on your vps.

There was a person here that had similar issues with performance and it turned out that he had created the database in another region so he had very long response times.

Activity icon

Replied to Storing Laravel Snippits Inside A Database.

As a rule of thumb don't store code in your database.

Building a dynamic menu is quite easy.

Create a table for you menu entries

  • id
  • title
  • link (only needed if you deviate from the standard route convention).

Load the entries from the database and pass them to your view.

In your view itterate through the entries

<nav>
@foreach($menuEntries as $entry)
	<a href="{{ $entry->link }}">{{ $entry->title }}</a>
@endforeach
</nav>
Oct
24
6 days ago
Activity icon

Replied to Database Design Tip.

With the correct indexes it's not a big chore for the database.

Activity icon

Replied to I've Been On This For Months Now And I Need Help

I recommend changing this

$table->boolean('read')->default(false);

To

$table->timestamp('read_at')->nullable();

Then you get for free when the person read you message.

Oct
23
1 week ago
Activity icon

Replied to Best Practice / Optimize Performance

I would start by running explain on the selects you have.

select `playername` from mutex
                    left outer join players
                    on players.name=`playername`
                    where mutex.i = 1
                    and players.name is null;

Most likely for this query you need an index on mutex.i and players.name.

SELECT id FROM players p WHERE p.name = playername);

This one should benifit from the players.name you added for the first select.

If you run explain on those two selects you most likely have full table scans and those should be fixed by asdding indexes to those tables.

Activity icon

Replied to Saving Json In Database, Casts

Even if you are building an api you still should use a proper database model.

https://laravel.com/docs/8.x/responses#json-responses

Activity icon

Awarded Best Reply on Complex Queries (select Clause) And Model Complex Database Scenarios

This one covers a lot of it. It does not cover the latest additions to Oracle SQL and MySQL8.

https://www.amazon.com/SQL-Bible-Alex-Kriegel/dp/0470229063

This might be a compliment to the book

https://www.w3schools.com/sql/

Activity icon

Replied to Saving Json In Database, Casts

That might not be the best database model for you. The thing you are trying to do defeats the whole purpose if a relational database.

Think rather of three tables.

  1. books
  2. stores
  3. book_stores

The last one is a pivot connecting the book to the store.

Activity icon

Replied to Complex Queries (select Clause) And Model Complex Database Scenarios

This one covers a lot of it. It does not cover the latest additions to Oracle SQL and MySQL8.

https://www.amazon.com/SQL-Bible-Alex-Kriegel/dp/0470229063

This might be a compliment to the book

https://www.w3schools.com/sql/

Oct
21
1 week ago
Activity icon

Replied to Performance Issues Advice

Have you tried adding indexes to the tables in question?

For example on your users table's email field.

CREATE INDEX users_email_idx
ON users (email);

To see if it goes any faster.

Oct
20
1 week ago
Activity icon

Replied to Performance Issues Advice

Inserts should never be that slow.

Is there some difference between the servers? For example is the database remotly hosted in production?

Activity icon

Awarded Best Reply on I'm Confused About Laravel

Laravel is a backend framework with frontend tools.

So with it you can build routing, controllers, models and views. You have some out of the box users handling and you have a nice wrapper when it comes to talking to the database such as Eloquent, migrations and seeders. You have other built in that helps you handle such things as sending emails, queue that you run in the background.

You can choose whatever you like to use on the frontend, Vue, jQuery, Angular, React or whatever javascript framework you'd like and the same goes for CSS frameworks like Bootstrap, Bulma Tailwind or any other you might like to use.

It all depends on what kind of application you are building.

If you are building something that has a lot of database transactions and not so much clientside javascript it's a very good option to use both for backend and presentation vith blade templates.

If you are building something that has a lot of clientsaide functionality you can use Laravel as you APi to the database and handle all communication with Ajax.

It's up to you to decide what you feel comfortable with.

However remeber this

Laravel is a serverside framework while all JavaScript frameworks are clientside.

I suggest you watch some of the free videos here or on youtube to see what Laravel is.

Laravel is not a CMS like Wordpress, it's a php framework that allows you to build any web application you like even a CMS ;)

Activity icon

Replied to Laravel Ajax

It depends a little on what browsers you want to support but with Firefox and Chrome you can do something like this.

A function that hadles all get requests

async function getRequest(url, parameters = {}) {
    try {
        let responsePromise = await fetch(url, { method: 'GET', headers: parameters});
        if(! responsePromise.ok) {
            throw new Error(responsePromise.status );
        }
        return await responsePromise.json();
    } catch (error) {
        return error;
    }
} 

You can then call it like this

async function getAuthorData() {
	let params = {
		'author': 'Rober Jordan'
	};

	const response = await getRequest('https://yoursite.com/api/getsomedataaboutauthor', params);

	//Get the #author-bio element and update with the one from the response
	document.querySelector('#author-bio').innerHTML = response.author_bio;
}
Activity icon

Awarded Best Reply on Select Thousands Of Record Problem

It's never a good idea to pull that much data out of the database at once.

Not knowing what you are trying to do with the data. I can only guess.

If it is for display purposes use pagination

https://laravel.com/docs/8.x/pagination

If it's for backend processing use chunks

https://laravel.com/docs/8.x/queries#chunking-results

Activity icon

Replied to Send If Is Checked

Something like this should work

<button onclick="submit()">Submit</button>
<span id="message"></span>
function submit() {
	el =	document.querySelector('#submit');
	if (el.checked) {
  		document.getElementById("myForm").submit(); 
	} else {
		message = document.querySelector('#message').
		message.innerHTML = 'Dude you need to check the checkbox';
	}
}
Oct
19
1 week ago
Activity icon

Replied to Select Thousands Of Record Problem

It's never a good idea to pull that much data out of the database at once.

Not knowing what you are trying to do with the data. I can only guess.

If it is for display purposes use pagination

https://laravel.com/docs/8.x/pagination

If it's for backend processing use chunks

https://laravel.com/docs/8.x/queries#chunking-results

Activity icon

Replied to Send If Is Checked

Something like this should work.

html

<input id="submit" type="checkbox" onclick="submit()">

js

function submit() {
	el =	document.querySelector('#submit');
	if (el.checked) {
  	document.getElementById("myForm").submit(); 
  }
}

You need to give the form you want to submit an id.

Oct
18
1 week ago
Activity icon

Replied to Updating More Then 50k Records

Sounds a bit like you do something first then the update/insert and that works as long as you don't have lots of rows in your database. There are some settings that you can change in your php.ini regarding execution times.

However I would check your code to make sure you don't do a lot of time consuming processing in php causing the timeouts.

Share your code for this so we can take a look.

Activity icon

Replied to Database Design : Timestamp Column Or Saperate History Table.

I would go with a product_history table where I'd store all the changes made. I would us a table trigger for this so I don't have to handle it with php.

https://www.w3resource.com/mysql/mysql-triggers.php

Activity icon

Replied to Phpunit Not Using In Memory Sqlite

What happens if you specify the phpunit.xml you want to use?

phpunit --configuration <path to your phpunit.xml>

Activity icon

Replied to Creating Db

There is a tutorial on multi renancy. I highly suggest you watch it.

https://laracasts.com/series/multitenancy-in-practice

I suggest you use one database for the all users instead of trying to add one for each user. Not only is creating databases and running migrations on the fly unecessary it's also way more complex and will likely cost a shitload more to run and maintain.

Also if your application is very successfull and gets lots of users you might run into problems with the filesystem. There seems to be a cap on 32K files

https://stackoverflow.com/questions/1740391/does-mysql-have-any-limitation-on-number-of-databases

Just add a user_id or a tenant_id to all your tables that way you can make sure the users don't see other users data.

Activity icon

Replied to Phpunit Not Using In Memory Sqlite

Maybe a stupid question but have you installed SQLite?

Oct
17
1 week ago
Activity icon

Replied to How To Prevent The Delete Of Table Row That Has It's Id In Another Table

That is a bad idea. Constraints is necessary to keep your data consistant. Not letting database help you handle the data consistensy and trying to do it in php is dubious at best.

I've said it before and will again. Never do anything in php that you can do in the database. The database is always faster and more efficiant and has functionality that has been proven for many years.

That being said, you are free to do as you please with your code.

Oct
16
2 weeks ago
Activity icon

Replied to Updating More Then 50k Records

Depends on what you are trying to do.

If it's something that needs to be done once only then do it with plain SQL.

If it's something that you need to do repetedly you can alway user a worker for it.

You can use transactions and chunk 5K records each iteration.

A little more information on what you are trying to achieve will make it easier to give better answer.

Activity icon

Replied to Database Design Tips For A Water Supply System.

Use one customer table.

There you can if you need have a customer type to differentiate between the two kinds of customers.

The common fields should be placed in the cutomers table the other fields that are not common can be placed in a seperate table(s).

Either you do it as a key value pair one table

  • customer_id
  • key
  • value

the plus on doing that is that you can have both customer types in the same table. The downside is that it's a little bit more tricky to query on those keys.

Or create it as a normal table with the fields needed for the customer type. Something like

  • industrial_customers_info
  • colony_customers_info
Activity icon

Replied to JSON In Database, Search For Entry By Value In JSON?

Yes and it will most likely be faster that using a like in you query

Activity icon

Replied to JSON In Database, Search For Entry By Value In JSON?

rdbms is Relational Database Management System in other words your database (MySQL, MariaDB, SQLite, Postgres, Oracle and so on).

It would give you 60 columns with a bad database model yes. In your case with a better database model it will give you a table something like this.

  • id
  • platform_id
  • user_id
  • key
  • value

key = 'Some json key" value = "The key value" key = 'some other json key" value = "another key value"

Oct
15
2 weeks ago
Activity icon

Replied to Unit Testing Views In Isolation

I have loads of those in my features directory. When it comes to testing views be careful not to make the tests brittle so that it breaks if you change the html structure or add and remove css classes.

Activity icon

Replied to JSON In Database, Search For Entry By Value In JSON?

I highly suggest you don't store values in json in the database. It will most likely bite you in the ass later on.

You can use a json column to store data temporarily then let a worker extract it and store it in the proper columns in your table.

By not using json in your database model you will be able to harness the full power of you rdbms.

Oct
14
2 weeks ago
Activity icon

Replied to Let's Build A Forum With TTD - Laravel 7

The differences are not that big so I say go for it.

Oct
13
2 weeks ago
Activity icon

Replied to Leaderboard Rewards

@jlrdw, one can only hope ;)

I was thinking more like to the one closest to your location.

Activity icon

Replied to Leaderboard Rewards

I like the idea of top contributer of the month. I would also not mind some nice swag like you mentioned, t-shirts, mugs and such. Maybe even a Laracon ticket for being the top contributer of the year or somesuch.

Oct
12
2 weeks ago
Activity icon

Replied to Getting "SQLSTATE[HY000]: General Error: 1364", For 'sub_category_id' As Well As 'item_description'.

That error means that you are trying to create a record without giving sub_category_id a value. You have three options,

  1. Make sure the sub_category_id is not null
  2. Add a ->default(<value>) to you migration
  3. Add ->nullable()to your migration.

I would go with the first option.

Oct
08
3 weeks ago
Activity icon

Replied to Request That Passes Values Into WhereIn Finds No Values That Are There

I tried this and it works fine.

 $request = ['a' => [1, 2, 3]];

 Book::whereIn('genre_id', $request['a'])->first();

So most likely $request['B'] is and empty array.

Activity icon

Replied to Request That Passes Values Into WhereIn Finds No Values That Are There

What do you get if you do a

dd($request['B']);