Tray2

Tray2

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

Member Since 5 Years Ago

Solna

Experience Points
252,970
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
1290
Lessons
Completed
Best Reply Awards
193
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
252,970 XP
Apr
02
12 hours ago
Activity icon

Replied to Migration Files Getting Out Of Hand

One migration per table as long as the project isn't launched then after that one for each changed table and release itteration.

You can probably make some changes and structure the migration files.

Something like

  • Migrations/Base Tables
  • Migration/Table Updates
  • Migration/Table Indexes

Or something similar of a single folder is getting too messy

Activity icon

Awarded Best Reply on Build Relation Of Two Table And Apply OnDelete('cascade). It's Not Working

table->id() is a bigInteger so all your foreign keys needs to be the same format.

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
Activity icon

Replied to Problem With Laravel/Installer + Composer

Have you tried

path/to/php73 ./composer.phar create-project laravel/laravel <project name> ?

Activity icon

Replied to Laravel- QR Code Hash

Something like that yes.

@snapey didn't know those existed, thanks for the heads up.

Activity icon

Replied to Input Fields Get Cleared

I'm guessing you are using aja to send the form so you most likely need to prevent default behaviour on your Save button which I guess is a submit button.

Activity icon

Replied to Build Relation Of Two Table And Apply OnDelete('cascade). It's Not Working

table->id() is a bigInteger so all your foreign keys needs to be the same format.

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
Activity icon

Replied to Getting Exception When Seeding With Decimals

Either change your comlumn type to decimal or add quotes in the migration.

'planned_advance_payment' => '0.29',
Activity icon

Replied to Laravel- QR Code Hash

You OrdersController needs to use the order number and the hash to be retrieved from the database.

 public function show(Request $request)
    {
        
        return view('qr.confirm-order')->with(['order'=>Order::where('purchase_num', $request->purchase_num)->where('hash', $request->hash)->get()]);
     
    }
Activity icon

Replied to Laravel- Scan QR Code For Customer To Verify

Yes.

An order number might look something like 5155255 and then the hash is to prevent anyone from just changing the order number manually in the url.

Activity icon

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

The order belongs to a purchase and to connect those you have a purchase_id in your orders table.

Why would you have a purchase_id in your purchase table?

If you use prefixes on your primary key then you would otherwise no.

You really should read up on foreign keys in relational databases.

Activity icon

Replied to Laravel- Scan QR Code For Customer To Verify

You need to create the hash when the order is inserted into your orders table.

Activity icon

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

You should have a purchase_id in the table connected to the model where you have that code.

So in your oders table you should have that column.

Activity icon

Replied to Laravel- Scan QR Code For Customer To Verify

Yes you can do that or just use the str::uuid() helper which generates a random unique identifier.

Activity icon

Replied to Laravel- Scan QR Code For Customer To Verify

https://yoursite.com/orders/confirm/<the order number>/<the hash> or something similar.

You should display a button to send a post request to confirm.

I updated the route suggested in the previous reply.

Activity icon

Replied to Laravel- Scan QR Code For Customer To Verify

There are several ways to do that.

One is to hash let's say the users email and order number

$hash = Hash::make($user->email + $this->orderno);

Or you can use uuid to generate a unique key

$id = Str::uuid();

Then you can use some endpoint like

Route:.get('orders/confirm/{order}/{hash}', '[email protected]');
Apr
01
1 day ago
Activity icon

Replied to Syntax Error, Unexpected End Of File

In my opinion yes. You should almost always match the model with a controller.

Activity icon

Awarded Best Reply on Difference Between Queries?

My guess is that the first one gives you a cartesian product and the other doesn't.

That basically means that you have duplicates in the first query. It adds all records together regardless of the where clause.

However that is just a guess.

Activity icon

Replied to Using Sanctum With A Vue SPA

The cors issue is what you get when using localhost. You need to use a proper domain for ajax.

Mar
31
2 days ago
Activity icon

Replied to Laravel 6 + Apache = Takes Almost All Memory

That looks to me like you really need to use the database for what it's made to do instead of using php to process the results.

Simplified example:

PHP side processing

$games = Game::all();
foreach($games as $game) {
	if($game->title == 'Quake') {
		//do something
	}
}

SQL side processing

$game = Game::whereTitle('Quake')->get();
//do something

The first example would most likely generate an 500 error if you have thousands of games in your table and use up way more memory then necessary.

The second example would use the RDBMS to get the data in an efficient memory lean way.

Activity icon

Replied to Laravel - Take 20 Rows Of The Latest Posts And Then Order By Column2

This would work as well

App\Post::latest()->limit(20)->orderBy('views', 'desc')->get();

And if it gets slow you can do

App\Post::latest()->limit(20)->orderBy('views', 'desc')->toSql();

Then you can run explain on your query to see where you need to add your indexes.

Your SQL would look like this

select * from `posts` order by `created_at` desc, `views` desc limit 20;

And with the explain it would look like this

explain select * from `posts` order by `created_at` desc, `views` desc limit 20;

And the result something like this

+------+-------------+---------+------+---------------+------+---------+------+------+----------------+
| id   | select_type | table   | type | possible_keys | key  | key_len | ref  | rows | Extra          |
+------+-------------+---------+------+---------------+------+---------+------+------+----------------+
|    1 | SIMPLE      | posts | ALL  | NULL          | NULL | NULL    | NULL | 3    | Using filesort |
+------+-------------+---------+------+---------------+------+---------+------+------+----------------+

Look for full table scan and try adding indexes to remove those.

Mar
30
3 days ago
Activity icon

Replied to Difference Between Queries?

My guess is that the first one gives you a cartesian product and the other doesn't.

That basically means that you have duplicates in the first query. It adds all records together regardless of the where clause.

However that is just a guess.

Activity icon

Replied to 404 Error When I Use FormRequest

So you are making a post request to https://somedomain.com/auth/register ?

Are you passing a valid CSRF token?

Activity icon

Replied to Still No Love For MongoDB?

Relational databases will probably never be obsolete but rather there is a time and place for everything.

https://www.integrant.com/when-to-use-sql-vs-nosql/

There are several packages for MongoDB already

https://medium.com/@alexrenoki/when-to-use-nosql-getting-started-with-mongodb-in-laravel-f5376ceaf545

https://github.com/jenssegers/laravel-mongodb

Activity icon

Replied to Didn't Understand Actual Mean Of Singleton , Anybody Can Explain Me ?

A singleton is mostly used instead of application wide global variable.

Activity icon

Replied to Can I Use QR Code To Scan And Update The Order Status?

A regular browser in the phone would be enough and the need to be signed in isn't mandatory. Though most courier firms have their own system to track shipments.

Activity icon

Replied to 404 Error When I Use FormRequest

Show us your routes, controller and blade file.

Activity icon

Replied to Can I Use QR Code To Scan And Update The Order Status?

In short yes it's doable.

The Qr code needs to contain a link to your finish order route with a uuid or similar that puts the order into finish state. You can use something similar to how Laravel handles the reset password link.

Mar
29
4 days ago
Activity icon

Replied to Laravel New Blog Throughs Error Copy() Failed To Open Stream Permission Denied

Since you are on a mac use Laravel Valet instead of mamp.

https://laravel.com/docs/7.x/valet#introduction

Then you can use a path like the one above.

Activity icon

Replied to Laravel New Blog Throughs Error Copy() Failed To Open Stream Permission Denied

Where are you installing it?

You should create a folder in your home directory for it something like

/Users/<user>/Code

And in it create your project.

Mar
28
5 days ago
Activity icon

Replied to Undefined Variable Posts In My Website (urgent)

Is the index file named ├Čndex.blade.php`?

Activity icon

Replied to After Executing The Tests Tables Are Removed

Then the test isn't using the phpunit.xml for some reason.

Activity icon

Replied to After Executing The Tests Tables Are Removed

What happens if you comment out all the sqlite settings in your .env file?

//DB_CONNECTION=sqlite   <--
//DB_HOST=127.0.0.1
//DB_PORT=3306
//DB_DATABASE=/home/my/path/db.sqlite   <--
//DB_USERNAME=root
//DB_PASSWORD=

And run the tests again?

Activity icon

Awarded Best Reply on Laravel Installing Won't Install On Local Server

Try

composer create-project laravel/laravel somedir

Activity icon

Replied to Laravel Installing Won't Install On Local Server

It tells composer what to download

Activity icon

Replied to Laravel Installing Won't Install On Local Server

Try

composer create-project laravel/laravel somedir

Activity icon

Replied to Laravel Installing Won't Install On Local Server

Do you have the right php version installed?

php --version should give version 7.3 or above.

Activity icon

Replied to After Executing The Tests Tables Are Removed

If you run ./vendor/bin/phpunit does it still empty your sqlite db?

Activity icon

Replied to PHP OOP Book

I liked the PHP Object-Oriented Solutions by David Powers isbn 9781430210115

https://www.goodreads.com/book/show/4479421-php-object-oriented-solutions?ac=1&from_search=true&qid=WsFW57sM0N&rank=1

Activity icon

Replied to After Executing The Tests Tables Are Removed

Then the test isn't using the phpunit.xml file but rather your .env file.

Are you sure the sqlite :memory: is ser in your phpunit.xml?

Are you running phpunit in the root of your project?

<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
Activity icon

Replied to After Executing The Tests Tables Are Removed

When using an Sqlite in memory database and database mirgrations it does the following

  1. Migrate the database
  2. Perform the test
  3. Rollback the database migration done before the test.

PHPUnit uses the phpunit.xml file to know which database to use and it does in your case don't use the one you specified in your .env file. To be able to log in using your browser you need to run php artisan migrate and then add a user so that you can use that to log in.

Mar
26
1 week ago
Activity icon

Replied to Loading Time - Website

I would check all the database queries and see if that some indexes are needed. You can use the laravel debubar for this or telescope.

Mar
25
1 week ago
Activity icon

Replied to Laravel 6 - TDD App - Table Includes App\Task As Subject_type?

You are probably refering to the Task instance instead of the task->id somewhere but it's hard to guess since you don't share your code.