Tray2

Tray2

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

Member Since 4 Years Ago

Solna

Experience Points
198,400
Total
Experience

1,600 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
1200
Lessons
Completed
Best Reply Awards
132
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 40
198,400 XP
Oct
22
4 hours ago
Activity icon

Replied to Using Js Framework

Yes it can in almost all cases. You can check this comparsion between them

https://scotch.io/bar-talk/vuejs-vs-jquery-use-cases-and-comparison-with-examples

Oct
21
1 day ago
Activity icon

Replied to DB Query Is Too Slow

This could be several reasons but I would start with making a copy of the categories table

CREATE TABLE categories2 AS SELECT * FROM categories;

Then I would try to do the same select from the newly created table.

SELECT * FROM categories2;

If that query is fast I would truncate the categories table.

TRUNCATE TABLE categories;

Copy the catogories back to the categories table

  INSERT INTO categories SELECT * FROM categories2;

And then run the select again.

SELECT * FROM categories;

And if it's still fast I'd drop the categories2 table

DROP TABLE categories2;

The table can get fragmented and that makes it slow.

Not the solution in this case but it's still a valid problem source. :)

Oct
19
3 days ago
Activity icon

Replied to What Wrong With My Seeder File??

And that will attutude will get so many more people inclined to help you.

Without any error message nobody can help you.

Oct
17
5 days ago
Activity icon

Replied to Parse Error: Syntax Error, Unexpected ';', Expecting ']' In App\Console\Kernel.php On Line 16

This line should not have a semi colon

protected $commands = [
        $this->load(__DIR__.'/Commands');
    ];

it should look like this

protected $commands = [
        $this->load(__DIR__.'/Commands')
    ];

Activity icon

Replied to Parse Error: Syntax Error, Unexpected ';', Expecting ']' In App\Console\Kernel.php On Line 16

I would start by checking all the files in the App/console directory since artisan reads the files there. Except kernel.php since you probably haven't made any changes there. Or maybe you have so check this part of the code

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];
Activity icon

Replied to Flow For Test Validation

I usually start with the happy path and make that pass then I add the validations one by one, A test for a table with authors would look something like

<?php

namespace Tests\Unit\Validation;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Author;

class AuthorValidationTest extends TestCase
{
    use RefreshDatabase;

    /**
    * @test
    */
    public function a_valid_author_can_be_stored()
    {
        $this->withoutExceptionHandling();
        
        $this->signIn();

        $author = factory(Author::class)->make([
            'first_name' => 'Robert',
            'last_name' => 'Jordan',
        ]);

        $response = $this->post('/authors', $author->toArray());
        $this->assertEquals(1, Author::count());
    }

    /**
    * @test
    */
    public function author_first_name_is_required()
    {
        $this->signIn();

        $author = factory(Author::class)->make([
            'first_name' => null,
            'last_name' => 'Jordan',
        ]);

        $this->post('/authors', $author->toArray())->assertSessionHasErrors('first_name');
        $this->assertEquals(0, Author::count());
    }

    /**
    * @test
    */
    public function author_last_name_is_required()
    {
        $this->signIn();

        $author = factory(Author::class)->make([
            'first_name' => 'Robert',
            'last_name' => null,
        ]);

        $this->post('/authors', $author->toArray())->assertSessionHasErrors('last_name');
        $this->assertEquals(0, Author::count());
    }

    /**
    * @test
    */
    public function authors_name_must_be_unique_to_stare_an_author()
    {
        $this->signIn();

        factory(Author::class)->create([
            'first_name' => 'Robert',
            'last_name' => 'Jordan'
        ]);

        $author = factory(Author::class)->make([
            'first_name' => 'Robert',
            'last_name' => 'Jordan'
        ]);

        $this->post('authors', $author->toArray())->assertSessionHasErrors(['first_name' => 'Author name not unique']);

        $this->assertEquals(1, Author::count());
    }
Activity icon

Replied to JQuery Ajax - When I Switch The Page It's Loading Blank Page - Laravel Pagination

You need to display the data in your page with javascript.

So when you receive the response you need to grab the containing element and change it's inner html to the new data.

Something like

<div id="#content">
    My original data is here
</div>

<script>
    function nextPage() {
      let response = JSON.parse(loadNextPage());

      let el = document.querySelector('#content');

      el.innerHTML =  parseToTable(response);
    }
    
    function parseToTable(response) {
        //Convert json to html table
    }
</script>

This is a very simplified example and will not work out of the box.

Activity icon

Replied to Unique Validation Encrypted Database

Depends on the encryption method. If it's the same result every time you encrypt a string then yes otherwise no.

If you use the enterprise edition of mysql you can use it's built in protection and handle all as you normally would

https://www.mysql.com/products/enterprise/encryption.html

However that is quite expensive to buy.

Activity icon

Replied to Symlink Not Working On Windows

Check this guide out on how to create symlinks on Windows.

https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

But then again I highly suggest you get an *nix machine to develop on since 99% (maybe a bit exagerated) of the tutorials are done on *nix system and yes the system Jeffrey is using is a *nix based system.

Oct
16
6 days ago
Activity icon

Replied to Symlink Not Working On Windows

Windows does not have symlinks. They have something similar. I suggest you use a virtual machine running a linux distribution (Ubuntu, CentOs or similar) to host your site. Then you will have a environment that is quite close to the production environment.

Here is a guide for Ubuntu

https://www.howtoforge.com/tutorial/ubuntu-laravel-php-nginx/

Activity icon

Replied to Avoid Refreshing Page At Pagination Laravel

Then you need to handle that with JavaScript and Ajax to make a request to your endpoint and then rerender your page with the new data.

Activity icon

Replied to Php Tinker

Tinker is just a php shell that has access to your laravel application.

In it you can try your code or tinker with it without making changes in your source code.

For example you can try out Eloquent queries to see if you get the expected result.

You can also test your eloquent relationship.

It's kinda like the developer tool console in your browser where you can run javascript on your page but for php.

Activity icon

Replied to Episode 9 - How Do I Create Nested Comments By Laracasts

What method?

You can use pagination.

Activity icon

Replied to Join Two Encrypted Table.

Yes, you use the primary and foreign key, which I really hope you haven't encrypted.

Not really understanding why you want to encrypt the database since it will give you a big headache.

If you still want/need to encrypt do it only with the sensitive data and not everything.

Oct
15
1 week ago
Activity icon

Replied to Query Gets Extremely Slow

Lets say you have a list of id like this

1
2
3
4
5
6
7
8
9
10

and you are looking for id 10, It will start at the top and check all the ids till it reaches the matching one. An index looks something like this

1-5                      6-10
  1-3    4-5           6-8  9-10

So it will first check if the 10 is within the first 1-5 group it's not so it will choose the 6-10 group and then it will check if it's within the 6-8 group since it's not it will choose the 9-10 group and find the record.

So instead of doing ten comparsions it does three or four. This wont matter in a small table but if you have thousands or hundreds of thousands of rows it makes a huge difference.

Oct
14
1 week ago
Activity icon

Replied to Query Gets Extremely Slow

Add an index to the table on category_id

Activity icon

Replied to Query Gets Extremely Slow

You are using LIKE and that is always slow since it will require full table scans. Use = where possible.

Activity icon

Replied to Which Debit Card Work Perfectly With Laracast Subscription?

The card might need to be activated for internet transactions. I know my bank requires my to login and activate it for internet transactions.

Activity icon

Replied to Laravel Collective Form Value Select From Database And Show Others Value Name Problem

I really do suggest you write your own forms instead of using the Laravel collective c.r.a.p.

What is the problem you are facing? Any error messages? What is it you are trying to achive?

Oct
13
1 week ago
Activity icon

Replied to How To Sum Up Numbers In Two Or More Input Fields

Somthing like

document.querySelector('#subtotal').value = parseFloat(document.querySelector('#field_1').value) * parseFloat(document.querySelector('#field_2').value);

Should work.

Oct
12
1 week ago
Activity icon

Replied to Packages Development Add Layout Error

Show us some code of what you are trying to do and what the error message is.

Activity icon

Replied to Shorter Version Of This Query

You can use whereIn.

Activity icon

Replied to OrderBy Average Using DB Class

Since you are using the AVG aggregate to generate a column in the result set you can't just order by it.

This would not work

select id, title, avg(rating) as average_column
from some_table
order by average_column

This would

select id, title, avg(rating) as average_column
from some_table
order by avg(rating)

The first example is ->orderBy('average_column') and the second is ->orderByRaw('avg(rating)')

!!! The examles are pseudo code and are very simplified and will not work out of the box. !!!

Activity icon

Replied to Fetch Data From Encrypted Table

You can index the shit out of that table but it still will not help with performance since the values are different and you need to check every row until you hopefully find a match.

Like I wrote in the other thread

https://laracasts.com/discuss/channels/laravel/login-using-encrypted-email-with-laravel-authattempt

It's not a good practice.

You can of course use md5 + salt and pepper then it will always be the same.

Activity icon

Replied to Login Using Encrypted Email With Laravel Auth::attempt

Generally I would not encrypt the email or the username since they are often displayed in your application as plain text. Encryption also puts more stress on the server.

Depending on which method you use the encrypted string might change just as you are experiencing. The way password encryption works in Laravel. If you use the same method of encryption you can never decrypt the email and use it in your application. It's a one way encryption.

If you want to use encryption it must be a decryptable one for other values than the password.

openssl_encrypt and openssl_decrypt can help you with that.

https://www.php.net/manual/en/function.openssl-encrypt.php https://www.php.net/manual/es/function.openssl-decrypt.php

Oct
10
1 week ago
Activity icon

Replied to Input Field

You mean like this?

<input type="text" name="product" placeholder="Product">
Activity icon

Replied to Create A New Primary Column In Production

Happy it worked out for you :)

Activity icon

Replied to Concatenation

You are mixing single and double quotes.

Use single quotes as the wrapper

someVariable = '<tr><td style="padding: 5px;">' + someValue  + '</td></tr> ';

Then again you should almost never use inline styles like that.

Activity icon

Replied to Create A New Primary Column In Production

Yes, in your sqlfile you change one table at the time.

Something like

CREATE TABLE some_table_temp AS SELECT * FROM some_table;

DROP some_table;

CREATE TABLE some_table (
    id NOT NULL AUTO_INCREMENT,
    field1 varchar(255),
    field2 varchar(255),
    PRIMARY KEY (id)
);


INSERT INTO some_table 
SELECT * FROM some_table_temp;

DROP some_table_temp;

Should work.

Activity icon

Replied to Get Data Of Day, Week, Month, YEAR

For year you ca do something like

SELECT * FROM sales WHERE YEAR(created_at) = '2019';

There are aggregates you can use for month, week and day too

You can check it here https://www.w3schools.com/sql/func_mysql_year.asp

Activity icon

Replied to Get Data Of Day, Week, Month, YEAR

What kind of data do you have and what is the expected result?

Activity icon

Replied to Create A New Primary Column In Production

You write the sql code for it and

mysql -u username -p database_name < file.sql

Activity icon

Replied to Order By Not Working

Group by usually requires a aggregate like sum() or avg() something like this query

SELECT sum(in_stock) stock, some_field2, some_field3
FROM some_table
GROUP BY some_field2, some_field3
ORDER BY some_field1

Not knowing your data or what you expect as the result it's hard to help. Rule of thumb don't use group by unless you use an aggregate that requires it.

In your case from the qurey you've written you might be looking to sort on more than one column.

Category::orderBy('company')->orderBy('category')->get();
Activity icon

Replied to Create A New Primary Column In Production

Why not create a temporary table and copy the data into it then drop the original table and recreate it the way you want it then move the data back.

Oct
09
1 week ago
Activity icon

Replied to How To Write Regex In Laravel

I recommend using http://regexr.com to test your regular expressions.

Something like

[a-z]{3}-[a-z]{3}-[a-z]{3}

should do the trick

Activity icon

Replied to Converting Website To Laravel (Old Database)

I would use an extra column in the customers table where I store the old primary key and the same for the other tables where you use it as foreing key. Then I can run something like

INSERT INTO table2
SELECT * FROM table1 

And then do an update of the foreign key Something like

UPDATE table set foreign key = (select id from table2, table  where table.old_id = table2.old_id

And lastly drop the old_id columns

Oct
04
2 weeks ago
Activity icon

Replied to Table Migration Social Account

If you are not concerned about your data you can try running php artisan migrate:refreshIt will drop all the existing tables and migrate them again. It will not drop anything you createdmanually.

Activity icon

Replied to Can You Help With Laravel Installation?

I sugget you read this guide on how to set up your machine.

https://www.howtoforge.com/tutorial/ubuntu-laravel-php-nginx/

Oct
02
2 weeks ago
Activity icon

Replied to Model/Database Structure For Org/Admin/Users

I would have three tables, users, organizations and organization_users.

I would set the admin in the pivot organzation_users table.

Activity icon

Replied to How To Prevent Guest From Keeping Inserting Data To The Database

You can't do that with 100% certainty.

But you can use cookies and session to try to prevent it but by a simple clearing of the cookies the user can rate again.

Activity icon

Replied to Ajax Not Working On Laravel 5.8

What does the browsers development tools tell you?

Oct
01
3 weeks ago
Activity icon

Replied to Overriding Relationship Behavior

You could probably just add the relationships to your base model class or you could try updating Illuminate/Database/Eloquent/ConcernsHasRelationships.php.

Activity icon

Replied to Overriding Relationship Behavior

If you have a relationship like this

 public function format()
 {
    return $this->belongsTo(Format::class);
 }

You could do something like this

 public function format()
 {
    if ($this->format_id == 0) return null;
    return $this->belongsTo(Format::class);
 }
Activity icon

Replied to Adding Suggestions To Command Line

The simple answer is no. It's possible to build something in Python that acts like a shell but that requires a bit of coding.

Activity icon

Replied to When Run Existing Laravel Project In My Local Computer File Downloaded

The purpose is that you can quickly boot up a server so you demo or test you application localy without having Apache or nginx installed.

You could also use it for development but I would suggest using Valet or Homestead for it instead so that you have a more production like environment.