extjac

Member Since 6 Years Ago

Experience Points
18,895
Total
Experience

1,105 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
168
Lessons
Completed
Best Reply Awards
3
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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 4
18,895 XP
Apr
08
5 days ago
Activity icon

Started a new Conversation Route Model Implicit And Explicit Binding

I am able to use Route Binding when the model is a single word....example below

#Model
class Post extends Model
{
}

#route
Route::get('/posts/{post:uuid}', '[email protected]'); 

however, I am not able to make it work when the model has a name with two words..example: PostComments

#Model
class PostComment extends Model
{

}

#route
Route::get('/postcomment/{postcomment:uuid}', '[email protected]'); 

how can i use this type of name in a route?

Apr
01
1 week ago
Activity icon

Awarded Best Reply on S3 Upload & Download

tried this and it worked

	public function download()
	{

		request()->validate([
			'filename' =>'required',
			'path' =>'required',
		]);

	
		$path = request()->path;
		
		$filename = request()->filename;
		
		return \Storage::disk('s3')->download($path.$filename);

	}
Activity icon

Replied to S3 Upload & Download

tried this and it worked

	public function download()
	{

		request()->validate([
			'filename' =>'required',
			'path' =>'required',
		]);

	
		$path = request()->path;
		
		$filename = request()->filename;
		
		return \Storage::disk('s3')->download($path.$filename);

	}
Activity icon

Replied to S3 Upload & Download

currently you cant open it with just the url. You need to use the download route to do so. But i am not happy with the code. I am hopping there is better way to do it.

Mar
31
1 week ago
Activity icon

Started a new Conversation S3 Upload & Download

I am using S3 to upload and download files. The files needs to be private; they cant be public.

The below code actually works, but I was wondering whats the correct/better way to do the download?

# the upload codes looks something like this....

$file = request()->file('file_name');

$file_name = \Str::random(9) . $file->getClientOriginalName() );

$path = 'secure/files/' ;

\Storage::disk('s3')->put( $path.$file_name , file_get_contents($file)  ); //,  'public'

//Save file in in the DB

and the download codes looks like this

<?php

namespace App\Helpers;


class S3
{

	public function download()
	{

		request()->validate([
			'filename' =>'required',
			'path' =>'required',
		]);

	
		$path = request()->path;
		
		$filename = request()->filename;

		$file = \Storage::disk('s3')->get($path.$filename);

		$headers = [
		    'Content-Type' => 'text/csv', 
		    'Content-Description' => 'File Transfer',
		    'Content-Disposition' => "attachment; filename={$filename}",
		    'filename'=> '{$filename}'
		];

		return response( $file, 200, $headers );

	}


}

Download route looks like this

Route::get('/download', '\App\Helpers\[email protected]')->middleware('auth');

and use it like this

<a  href="{{ url("download?filename={$file->name}&path={$file->path}") }}" > Open </a>
Mar
18
3 weeks ago
Activity icon

Commented on Build The Blog Post Page

ho man...this series was amazing! The speed was perfect!

Mar
07
1 month ago
Activity icon

Replied to Laravel Excel Fopen File Does Not Exist.

for me 755 works with below path. /myapp/storage/framework/laravel-excel Try with 777 just to see...then switch back to 755

Mar
04
1 month ago
Activity icon

Replied to Laravel Chmod 755 Vs 777

I was playing this morning with this...set folders to 755 or 775, ran the command below, and still laravel shows the 500 error / permission denied.

sudo chown -R www-data:www-data /opt/bitnami/apache/htdocs/project_name/storage
Mar
03
1 month ago
Activity icon

Replied to Laravel Chmod 755 Vs 777

Thank you all for the comments.

I kind of understand the difference between 777 and 755. What I don't understand is that how someone will be able to upload a file under these folders; In theory, we just make the /public available...in my case, I am using S3 so there is not upload to the server.

Activity icon

Started a new Conversation Laravel Chmod 755 Vs 777

I use AWS EC2 and AWS Lightsail to host a few websites. Today i wanted to review the security to make sure that all is ok. I noticed that bellow folders I have them with 777. So i tried to changed to 755 but i get a 500 error

/bootstrap/cache
/storage/framework/cache/data
/storage/framework/sessions.
/storage/framework/views

how do you set up your folder access?

Mar
02
1 month ago
Activity icon

Awarded Best Reply on Simple Math Question...(sorry)

ignore

Activity icon

Started a new Conversation Simple Math Question...(sorry)

I am trying to calculate the invoice balance with this scenario....but my math is not working...

how would you calculate below formula?

Cost	1800
Paid	1800
Refund	1300
Discount 0
Balance	???
Feb
27
1 month ago
Activity icon

Replied to Google Charts

tried all combinations, Date or DateTime, changed the ->format() and cant make it work.

Feb
26
1 month ago
Activity icon

Started a new Conversation Google Charts

I am trying to create a simple timeline with google chart. But it seems that the date from is not working...and i tried a lot options...

this is just a simple example:

$bookings = \App\Booking::all('created_at', 'id');

foreach ($bookings as $key => $value) 
{

    $result[] = [$value->created_at->format('M d, Y H:i'), $value->id];

}

$data = json_encode($result);

but i get an error message regarding the date.

jsapi_compiled_default_module.js:213 Uncaught (in promise) Error: Type mismatch. Value Oct 22, 2020 11:52 does not match type datetime in column index 0
    at gvjs_oj (jsapi_compiled_default_module.js:213)
    at gvjs_9aa (jsapi_compiled_default_module.js:228)
    at gvjs_G.gvjs_.a_ (jsapi_compiled_default_module.js:230)
    at gvjs_G.gvjs_.Pp (jsapi_compiled_default_module.js:231)
    at drawChart (calendar:959)
Feb
19
1 month ago
Activity icon

Replied to Is This AWS Infra Secure?

I am a bit concerned about using the default VPC . I am not very good at networking so I am using the default one. Also, I am looking into WAF....but not sure how to implement it with AWS LightSail.

Activity icon

Started a new Conversation Is This AWS Infra Secure?

I am building a new app and I wanted to share the high level infra design hopping I could get some feedback from a security stand point and ways to improve it.

aws

https://ibb.co/7S3z0Fk

Activity icon

Started a new Conversation Can We Post Picture In This Forum?

Can we post pictures in this forum? i would like to share an AWS infra and ask a few questions

Feb
17
1 month ago
Activity icon

Awarded Best Reply on Relationships And WEHN() - Help!

found a way....

        return $this->hasMany( '\App\ItemPrice', 'item_id' )
        ->where('active', 1 )
        ->where( function( $query ){
            $query->where( \DB::raw('start_at' ) )
            ->orWhereDate('start_at', '<=', date('Y-m-d') );
        })
        ->where( function( $query ){
            $query->where( \DB::raw('end_at' ) )
            ->orWhereDate('end_at', '>=', date('Y-m-d') );
        })
        ->orderBy('item_tickets.position', 'ASC');
Activity icon

Replied to Relationships And WEHN() - Help!

found a way....

        return $this->hasMany( '\App\ItemPrice', 'item_id' )
        ->where('active', 1 )
        ->where( function( $query ){
            $query->where( \DB::raw('start_at' ) )
            ->orWhereDate('start_at', '<=', date('Y-m-d') );
        })
        ->where( function( $query ){
            $query->where( \DB::raw('end_at' ) )
            ->orWhereDate('end_at', '>=', date('Y-m-d') );
        })
        ->orderBy('item_tickets.position', 'ASC');
Activity icon

Started a new Conversation Relationships And WEHN() - Help!

I am trying to build an "item/prices" relationship where I can bring all the "Active" prices that belong to one item/product.

The challenge is that "some" prices might have a start and end dates (START_AT and END_AT) and some prices might not...but both could be active.

I tired a few things but cant make it work...... see bellow..

Any recommendations?

 class Item extends Model
{
   public function prices()
    {

        return $this->hasMany( '\App\ItemPrice', 'item_id' )
        ->where('active', 1 )
        ->when( 'start_at' , function($query) {
            $query->whereDate('start_at' , '<=' , date('Y-m-d') );
        })
        ->when( 'end_at', function($query) {
             $query->orWhereDate( 'end_at' , '>=' , date('Y-m-d') );
        })        
;

    }
}

Options 2

class Item extends Model
{
    public function prices()
    {
        return $this->hasMany( '\App\ItemPrice', 'item_id' )
        ->where('active', 1 )
        ->where( function($query) {
            $query->where( \DB::raw('start_at is null') ) 
            ->orWhereDate('start_at' , '<=' , date('Y-m-d') );
        })
        ->where( function($query) {
            $query->where( \DB::raw('end_at is null') ) 
            ->orWhereDate( 'end_at' , '>=' , date('Y-m-d') );
        })        
;
    }
}
Feb
13
2 months ago
Activity icon

Started a new Conversation Insurance

I am from Canada and I am developing a SaaS. I would like to get a software/Data/Cyber insurance. any recommendations?

Feb
12
2 months ago
Activity icon

Replied to Taxes

I just wanted to know how other people store the taxes in the DB. Meaning...do you store 15% or do you store 0.015 Do you store it as char or number or float.

Activity icon

Replied to Taxes

Right...but as a business Owner you can chose to charge Price+tax or include the tax on the price. Just trying to see how people store tax values. As I said, a bit simple.

Activity icon

Started a new Conversation Taxes

How do you handle and store product taxes? I am planning just to create a table where the customer can create their own taxes and then apply to products. Very simple approach.

Do you store taxes as a % ex: 15% or a number 0.015??

Feb
10
2 months ago
Activity icon

Started a new Conversation Code Cleanup

I am trying to clean up my code a bit. I just wanted to know if below make sense or if there is a better way to refactor.

I created a helper class to process Authorize.net payments that is going to be used by the OrderController.

<?php

namespace App\Helpers;

use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;

class AuthorizeDotNet
{
    public function __construct()
    {
        $this->appID = env('LOGIN_ID') ;
        $this->key = env('KEY');
    }


	public static function chargeCreditCard()
	{
		/// code goes here.....
	}

	public static function chargeDebitCard()
	{
		/// code goes here.....
	}

}

Then I am planning to use it like this...


namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class OrderController extends Controller
{
	
    public function processPayment( )
    {
		App\Helpers\AuthorizeDotNet::chargeCreditCard( );
	}
	
}

and update composer.json

    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories",
            "app/Helpers"
        ]
    },
Jan
25
2 months ago
Activity icon

Replied to Http 500 Error When I Try Post Request

to start i would change the POST to post. Then the controller is waiting for an ID that the router not is not passing and set APP_DEBUG=true

Dec
16
3 months ago
Activity icon

Awarded Best Reply on Query WhereYear() WhereInYear()

this seems to be working....

 $query->whereIn( \DB::raw('year(birthday)'), request()->year );
Activity icon

Replied to Query WhereYear() WhereInYear()

this seems to be working....

 $query->whereIn( \DB::raw('year(birthday)'), request()->year );
Activity icon

Replied to Query WhereYear() WhereInYear()

it is birthday....something like.... 2010-01-01

->whereYear('birthday', $year)
Activity icon

Started a new Conversation Query WhereYear() WhereInYear()

in my query I am able to do

whereYear() 

but i need something like

whereInYear()

how would you do it?

Activity icon

Started a new Conversation Laravel + Square

Has anyone managed to implement Square order, invoices API etc?

Dec
03
4 months ago
Activity icon

Replied to Opinions Please: DigitalOcean Or Linode?

if you want something cheap and simple, I use https://aws.amazon.com/lightsail/

Nov
11
5 months ago
Activity icon

Commented on Refactor To A BelongsToTenant Trait

cant use use the auth()->user()->tenant_id instead of the session()->put()?

Nov
08
5 months ago
Activity icon

Started a new Conversation Intervention Image

I have people uploading pictures with dimensions over 7000 by 7000 px. and the server cant process them. How much memory do you allocate to the server to be able to handle large image dimensions.

Nov
01
5 months ago
Activity icon

Replied to Laravel 8 Routes Broken

did you import the controller to the route file?

Oct
26
5 months ago
Activity icon

Awarded Best Reply on AWS SES -

Some Australia iMessage email saying "you have a voicemail." I deleted the Keys, contacted AWS, they clear the SES queue. i dont know how they could have got the keys. I concern now.

I know sometimes laravel will through an error and dump the .env file if you are in debug mode; but this is not the case.

Activity icon

Replied to AWS SES -

Some Australia iMessage email saying "you have a voicemail." I deleted the Keys, contacted AWS, they clear the SES queue. i dont know how they could have got the keys. I concern now.

I know sometimes laravel will through an error and dump the .env file if you are in debug mode; but this is not the case.

Activity icon

Replied to AWS SES -

nope...nothing. Just a register and login. The Laravel out of the box

Activity icon

Started a new Conversation AWS SES -

I pushed a Laravel App last week to "production". I am using AWS services; AWS Beanstalk and AWS lightSail. For emails, I am using AWS SES. Today I received 2000 emails bounces from AWS and the account suspended. It looks like that last night my SES account sent 160k emails (spam).

I dont even understand how this happen. AWS account is one week old; with bran new keys. I am using github private repo to push data into AWS or Zip files.

did anyone has this issue with Laravel and AWS SES?

Oct
23
5 months ago
Activity icon

Awarded Best Reply on AWS Lightsail

I manged to use AWS LightSail with HTTPS and AWS LightSail + Load Balancer and Https.

Steps to get Https only:

1- Create Instance using LAMP Bitnami 

2- SSH and git clone your repo: 
# cd htdocs
# sudo git clone {your git url}

3- Edit and Apache config file
# sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public"
<Directory "/opt/bitnami/apache/htdocs/yoursite/public">

5- Create the certificate
# sudo /opt/bitnami/bncert-tool
And follow the steps

6- Edit and Update Apache SSL config file

# sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf

<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public"
<Directory "/opt/bitnami/apache/htdocs/yoursite/public">

7-restart Apache
# sudo /opt/bitnami/ctlscript.sh restart apache

8-Create an A record pointing to instance IP

Steps to get Load Balancer and Https:

1- Create Instance using LAMP Bitnami 

2- SSH and git clone your repo: 

# cd htdocs
# sudo git clone {your git url}

3- Edit Apache config file

# sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

4- Update app root folder :

<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public"
<Directory "/opt/bitnami/apache/htdocs/yoursite/public">

5- Force HTTPS (https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/):

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

6- The bitnami.conf file should look something like this

# Default Virtual Host configuration.

# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on

<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public "
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

<Directory "/opt/bitnami/apache/htdocs/yoursite/public ">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

  # Error Documents
ErrorDocument 503 /503.html
</VirtualHost>

Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"

7-restart Apache
# sudo /opt/bitnami/ctlscript.sh restart apache

8- Create Load Balancer : Home / Network / Create Load balancer

9- Attach Instance

10-Create Certificate

11- Add CNAME records to your domain provider in order to validate certificate

12-Attach certificate to load balancer

13-Create an CNAME record pointing to load balancer

Notes: Please note that if you are using RDS you might need to allow traffic to LightSail instance IP. Also, you can enable the private instance IP through VPC peering. Account/Account/Advanced menu

Activity icon

Replied to AWS Lightsail

I manged to use AWS LightSail with HTTPS and AWS LightSail + Load Balancer and Https.

Steps to get Https only:

1- Create Instance using LAMP Bitnami 

2- SSH and git clone your repo: 
# cd htdocs
# sudo git clone {your git url}

3- Edit and Apache config file
# sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public"
<Directory "/opt/bitnami/apache/htdocs/yoursite/public">

5- Create the certificate
# sudo /opt/bitnami/bncert-tool
And follow the steps

6- Edit and Update Apache SSL config file

# sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf

<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public"
<Directory "/opt/bitnami/apache/htdocs/yoursite/public">

7-restart Apache
# sudo /opt/bitnami/ctlscript.sh restart apache

8-Create an A record pointing to instance IP

Steps to get Load Balancer and Https:

1- Create Instance using LAMP Bitnami 

2- SSH and git clone your repo: 

# cd htdocs
# sudo git clone {your git url}

3- Edit Apache config file

# sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

4- Update app root folder :

<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public"
<Directory "/opt/bitnami/apache/htdocs/yoursite/public">

5- Force HTTPS (https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/):

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

6- The bitnami.conf file should look something like this

# Default Virtual Host configuration.

# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on

<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs/yoursite/public "
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

<Directory "/opt/bitnami/apache/htdocs/yoursite/public ">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

  # Error Documents
ErrorDocument 503 /503.html
</VirtualHost>

Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"

7-restart Apache
# sudo /opt/bitnami/ctlscript.sh restart apache

8- Create Load Balancer : Home / Network / Create Load balancer

9- Attach Instance

10-Create Certificate

11- Add CNAME records to your domain provider in order to validate certificate

12-Attach certificate to load balancer

13-Create an CNAME record pointing to load balancer

Notes: Please note that if you are using RDS you might need to allow traffic to LightSail instance IP. Also, you can enable the private instance IP through VPC peering. Account/Account/Advanced menu

Oct
22
5 months ago
Activity icon

Started a new Conversation AWS Lightsail

Anyone with AWS Lightsail and load balance experience? i need to ask a few questions about AWS Lightsail Load balancer and HTTPS.

Oct
20
5 months ago
Activity icon

Replied to How Important And Necessary Is UUID At Laravel?

I use UUID mainly for is for security. I have the table ID and UUID. Usually the UUID is public and ID private. In addition, ID used for relationships.

Oct
19
5 months ago
Activity icon

Started a new Conversation Laravel And SquareUp Payments

has anyone use squareup.com as payment provider?

Activity icon

Replied to Laravel Application To Production Server Deployment

what Cloud provider are you using?