Tray2

Tray2

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

Member Since 5 Years Ago

Solna

Experience Points
286,740
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
1329
Lessons
Completed
Best Reply Awards
235
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
286,740 XP
Jun
01
1 day ago
Activity icon

Replied to Change Form Option To Laravel Collective

I suggest you remove the laravel collective completly since it's highly discuraged to use it. It's much better to use the standard html form elements. It will give you better readability, better control of your forms and make it easier to debug.

There are several threads here about it and in most of them you will get the same advice, don't use laravel collective forms.

Activity icon

Replied to How To Create Duplicate Of A Laravel Collection

No it's not since it's not using bindings. Try chaning it to something like

DB::select("SELECT player_id as player_id, SUM(total_runs) as total,tournament_id as tournament ,date as date 
        FROM results WHERE tournament_id= ? AND date = ? GROUP BY player_id ORDER BY total DESC", [$tournament->id, $date] );

Or like

DB::table('results')
	->selectRaw('player_id, SUM(total_runs) as total, tournament_id as tournament, date')
	->whereRaw('tournament_id = ?, date = ?', [$tournament->id, $date])
	->groupBy('player_id')
	->orderBy('total', 'desc')
	->get();

I haven't tried the queries but something like it should work.

May
31
2 days ago
Activity icon

Replied to "php Artisan Migrate" Gives Error

Make sure that the php<your version of php>-mysql is installed.

May
30
3 days ago
Activity icon

Replied to How To Create Duplicate Of A Laravel Collection

I suggest you push everything down into your database instead of processing it with php like you are doing. It's never good to process lots of data on the php side since it will never be faster than a properly written SQL query. If you let the database handle it you will only pull the data you need and not everything like you do now.

Since you don't show your data and your expected result it's hard to help you create such query,

Activity icon

Replied to Composer Install Error

apt-get is the package installer for Debian based Linux systems (Ubuntu, Xubuntu, Kunbuntu and a few others).

Try running these instead

brew update
brew install [email protected]
brew link [email protected]

https://stackoverflow.com/questions/58290566/install-ext-zip-for-mac

May
29
4 days ago
Activity icon

Replied to Laravel New App Installation Problem!

I suggest you upgrade your php version to at least 7.3. Since you need 7.2.5 to run Larvel 7.

https://laravel.com/docs/7.x/upgrade

Activity icon

Awarded Best Reply on Could A Unit Test Use Databases?

I would say it's a unit test since it test the $user->assignRole() method.

Yes a unit test can talk to the database if it needs to.

May
28
5 days ago
Activity icon

Replied to Composer Install Fails: SSL: Connection Reset By Peer

Just do a manual download then.

Not knowing your OS but if it's Linux chmod the file with sudo chmod +x composer.phar and them move it to usr/local/bin with mv composer.phar /usr/local/bin/composer

Activity icon

Replied to My If-Else Didn't Work In Laravel

FFS stop spamming the forum with the same question over and over.

Use your original thread as long as it's the same issue.

Activity icon

Replied to My If-Else Didnt Working

Read the error message again, It clearly states that judulcan't be null in your table.

So either allow null by making the field nullable or make sure you have a value in judul

Activity icon

Awarded Best Reply on Loading Spinner In Blade

This is how I do it in vanilla javascript and CSS

 <section id="loading">
    <div id="loading-content"></div>
  </section>
.loading {
	z-index: 20;
	position: absolute;
	top: 0;
	left:-5px;
	width: 100%;
	height: 100%;
    background-color: rgba(0,0,0,0.4);
}
.loading-content {
	position: absolute;
	border: 16px solid #f3f3f3; /* Light grey */
	border-top: 16px solid #3498db; /* Blue */
	border-radius: 50%;
	width: 50px;
	height: 50px;
	top: 40%;
	left:35%;
	animation: spin 2s linear infinite;
	}
	
	@keyframes spin {
		0% { transform: rotate(0deg); }
		100% { transform: rotate(360deg); }
	}


function showLoading() {
  document.querySelector('#loading').classList.add('loading');
  document.querySelector('#loading-content').classList.add('loading-content');
}

function hideLoading() {
  document.querySelector('#loading').classList.remove('loading');
  document.querySelector('#loading-content').classList.remove('loading-content');
}

To show the loader just call the showloading function.

May
27
6 days ago
Activity icon

Replied to How Add Permission To Storage Directory ?

A sudo chmod -R 755 storage should make it work or even 775

Activity icon

Replied to Could Not Open Input File: Composer.phar?.

And don't forget do sudo chmod +x /usr/local/bin/composer.

Activity icon

Replied to Background Image - How To Fit Screen Without Scrolling?

Try changing the background-size to contain

https://www.w3schools.com/cssref/css3_pr_background-size.asp

You should only have one rule for the background-size so change the first one to contain and remove the other.

background-size: cover;
background-size:fixed;
Activity icon

Replied to Why Many Topic In Laravel Section Are Outdates?

Some of the series use a slightly older version of Laravel yes, but the changes between the verions are not that big, so you will be able to correct the breaking ones. The upgrade guides in the documentation is really good.

As for the Laravel From Scratch Series that covers laravel 6 at the moment will teach you what you need to know and the few changes made between 6 and 7 will not create any major issues in your projects.

Laravel From Scratch + The Laravel documentation + Laravel Api docs + this forum should be enough for you to learn Laravel without too much problems.

Activity icon

Replied to How To Make Webkit Support In All Other Browsers?

A bit of both actually :)

Activity icon

Replied to Text-capitalize Is Not Working?

It does work but not the way you intended.

If you put the class on the option it will capitalize the option but not the selected value. So what you need to do is put the class on the select instead.

 <select class="form-control text-capitalize" id="gender_id" name="gender_id">
Activity icon

Replied to How To Make Webkit Support In All Other Browsers?

Why don't you check here what you can use in each browser.

https://caniuse.com/#search=scrollbar

And also this site is really good.

http://dowebsitesneedtolookexactlythesameineverybrowser.com/

May
26
1 week ago
Activity icon

Awarded Best Reply on Laravel Testing - Can't Connect To DB On Unit Test (but Works Perfectly In Feature Test)?

The two file extends different Testcase classes. The feature test extends Tests/Testcase while the unit test extends PHPunits testcase. Just change the uses clause for the Testcase in your unit test and make it look like it does in your feature test.

Activity icon

Replied to Laravel Testing - Can't Connect To DB On Unit Test (but Works Perfectly In Feature Test)?

The two file extends different Testcase classes. The feature test extends Tests/Testcase while the unit test extends PHPunits testcase. Just change the uses clause for the Testcase in your unit test and make it look like it does in your feature test.

Activity icon

Replied to I Need Help Using Kenyan Payment Gateway

Laravel is PHP.

A quick serach and I could not find any package for this and about the only thing I could find is a Wordpress plugin.

May
25
1 week ago
Activity icon

Awarded Best Reply on Database (database/database.sqlite) Does Not Exist. (SQL: PRAGMA Foreign_keys = ON;)

I started a new project today and decided to use Sqlite instead of MySql and ran into the same issue.

You need to add the full path to your databae.sqlite.

In my case it's /home/tray2/code/<project-name>/database/database,sqlite

So in your case is something like C:\Users\<your-user>\<project-name>\database\database.sqlite

https://stackoverflow.com/questions/43140711/database-database-database-sqlite-does-not-exist-database-works-from-artisan

Activity icon

Replied to Database (database/database.sqlite) Does Not Exist. (SQL: PRAGMA Foreign_keys = ON;)

The easiest would be to ssh into your DO-box and go to your document root and type pwd.

It will print your current working directory.

Just add the output and the pwd command + /database/database.sqlite to your env file and you should be good to go. The path migth look something like this

/var/www/html/public/database/database.sqlite

just a sidenote.

I would most likely not use sqlite in production but rather use a MySQL/MariaDB database. It of course depends on how much data you are going to store in the database.

Activity icon

Replied to Database (database/database.sqlite) Does Not Exist. (SQL: PRAGMA Foreign_keys = ON;)

I started a new project today and decided to use Sqlite instead of MySql and ran into the same issue.

You need to add the full path to your databae.sqlite.

In my case it's /home/tray2/code/<project-name>/database/database,sqlite

So in your case is something like C:\Users\<your-user>\<project-name>\database\database.sqlite

https://stackoverflow.com/questions/43140711/database-database-database-sqlite-does-not-exist-database-works-from-artisan

Activity icon

Replied to While Installing Laravel Composer

I always install laravel the same way as @jlrdw

Activity icon

Replied to While Installing Laravel Composer

I suggest you take a look at one of these guides on how to setup your environment for Laravel

NginX

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

Apache 2

https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/

Activity icon

Replied to Could A Unit Test Use Databases?

I agree with @tykus on this

Personally I don't care what it is called, or if it touches the database once it gives me confidence about my application(s) working as expected.

Activity icon

Replied to Could A Unit Test Use Databases?

I would say it's a unit test since it test the $user->assignRole() method.

Yes a unit test can talk to the database if it needs to.

Activity icon

Replied to Get Total (video Durations) With GetID3

Just a tip. Try to do the sum in the sql query instead of with php after the fetch.

Activity icon

Replied to Get Total (video Durations) With GetID3

I would store that information in a field in a table on each upload then it's way easier to get in on demand without accessing the file system and every file every request.

Activity icon

Replied to Loading Spinner In Blade

This is how I do it in vanilla javascript and CSS

 <section id="loading">
    <div id="loading-content"></div>
  </section>
.loading {
	z-index: 20;
	position: absolute;
	top: 0;
	left:-5px;
	width: 100%;
	height: 100%;
    background-color: rgba(0,0,0,0.4);
}
.loading-content {
	position: absolute;
	border: 16px solid #f3f3f3; /* Light grey */
	border-top: 16px solid #3498db; /* Blue */
	border-radius: 50%;
	width: 50px;
	height: 50px;
	top: 40%;
	left:35%;
	animation: spin 2s linear infinite;
	}
	
	@keyframes spin {
		0% { transform: rotate(0deg); }
		100% { transform: rotate(360deg); }
	}


function showLoading() {
  document.querySelector('#loading').classList.add('loading');
  document.querySelector('#loading-content').classList.add('loading-content');
}

function hideLoading() {
  document.querySelector('#loading').classList.remove('loading');
  document.querySelector('#loading-content').classList.remove('loading-content');
}

To show the loader just call the showloading function.

Activity icon

Replied to Database (database/database.sqlite) Does Not Exist. (SQL: PRAGMA Foreign_keys = ON;)

I'm not using Windows so I can't help you there.

Activity icon

Replied to SQLite Foreign Key Dont Set Null On Delete In Phpunit Test

The main reason is that if you put a foreign key constraint on a table, let's say the users table.

  • id
  • username
  • password
  • profile_id

That means that every user must have a profile and that is all good.

However in your case, a question does not always have a best reply.

Then it's not optimal to put it on the query

  • id
  • query
  • user_id
  • best_reply_id

so instead you move the best reply to the replies table instead

  • id
  • query_id
  • reply
  • user_id
  • best_reply

Or even move it to a pivot table best_replies or some such

  • question_id
  • reply_id

That makes more sense at least to me than making it nullable.

Activity icon

Replied to Database (database/database.sqlite) Does Not Exist. (SQL: PRAGMA Foreign_keys = ON;)

Do you have a database.sqlite in the database directory? Does the webserver have read and write access to it?

Just a guess here but when you run it manually (from the command line) you do that as your user but when you access the route with the browser the webserver is trying to access it and it most likely does not have the correct permissions.

Are you using a *nix (linux/unix/MacOs) machine or are you running Wind0ze?

May
24
1 week ago
Activity icon

Replied to Controller Input Validation Help

It's a select so why would you limit it to 30 characters?

The values of the select box is most likely loaded from a table, that tables primary key is the values.

Something like this

 <label for="cars">Choose a car:</label>

<select name="cars" id="cars">
  <option value="1">Volvo</option>
  <option value="2">Saab</option>
  <option value="3">Mercedes</option>
  <option value="4">Audi</option>
</select> 

So what you should be checking is that the value passed in the request (1,2,3 or 4) exists in the cars table in the database.

'car_id' => 'required|exists:cars,id',
Activity icon

Replied to S3 Uploading PDF From HTML

From the class

    public function set_base_path($path)
    {
        $this->setBasePath($path);
    }

    /**
     * Sets the base path
     *
     * @param string $basePath
     * @return $this
     */
    public function setBasePath($basePath)
    {
        $this->basePath = $basePath;
        return $this;
    }

One of them should work.

https://github.com/dompdf/dompdf/blob/master/src/Dompdf.php

Activity icon

Replied to S3 Uploading PDF From HTML

Can't you just do

$pdf->setBasePath(Storage::disk('s3') . '/path/to/folder/');
$pdf->output();
Activity icon

Replied to Laravel 6 On Heroku. Forbidden You Don't Have Permission To Access This Resource.

What is your document root?

is it pointing to the public folder or is it pointing to the project root?

Activity icon

Replied to Laravel 7 ForeignID() Migrations

Yes the issue is that the tables must be created in the correct order otherwise it will fail.

You can turn foreign key checks of then migrate and then turn the checking back on again.

https://tableplus.com/blog/2018/08/mysql-how-to-temporarily-disable-foreign-key-constraints.html

That should help with the integrity constraints.

As for the second question I would say yes create an index for both it will make the searching faster. Remeber that the order of the keys are important to the parser. They should be in the same order in your query or the index isn't used.

You should not declare them as primary key unless they really are unique, just create a regular composite index.

May
23
1 week ago
Activity icon

Awarded Best Reply on Library

Sorry no but take a look here https://packagist.org/?query=math

Activity icon

Replied to How To Do A Query Search In Multiple Tables?

Rule number one never do anything in php that the database can do for you.

Since you have the same structure on all tables why not just make it one table?

  • id
  • json
  • type

That would look something like this in the table

1   {"title": "Some title"}            games
2   {"title": "Some other title"} books
3   {"title": "A third title"}          movies

So to get all the books you just do

Product::whereType('books')->get();

And to get everything just

Product::All();

I'm very allergic to using json in the database since it kind off defeats the purpose but it makes the query above much easier.

If you don't change to one table I suggest you do a database view with unions

CREATE VIEW all_products AS
SELECT id,
	     json,
             'books' AS type
FROM table1
UNION ALL
SELECT id,
	     json,
             'movies' AS type
FROM table2
UNION ALL
SELECT id,
	     json,
             'games' AS type
FROM table3

And so on.

Then you can query it the same way you would a single table.

https://dev.mysql.com/doc/refman/8.0/en/create-view.html