stargatesg1

Experience

6,585

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 18 Lessons Completed
  • 0 Favorites

26th April, 2018

stargatesg1 started a new conversation Mailtrap Email Error • 3 weeks ago

For some reason when sending a email on my local machine. I am getting the following error

POSTXHRhttp://www.devqi.com/api/workshop[HTTP/1.1 500 Internal Server Error 2182ms] 
HeadersCookiesParamsResponseTimingsStack TraceJSONstatuserrorexceptionSwift_TransportExceptioncodeSystemErrormsgfile/www/restoredqi/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.phpline268Response payload 1{"status":"error","exception":"Swift_TransportException","code":"SystemError","msg":"Connection could not be established with host smtp.mailtrap.io [Unable to find the socket transport \"plain\" - did you forget to enable it when you configured PHP? #1]","file":"\/www\/restoredqi\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/StreamBuffer.php","line":268}

Any ideas as to why.

5th April, 2018

stargatesg1 left a reply on Sending Emails To A User That Isn't Logged In • 1 month ago

I am using mailtrap on my local machine to test

stargatesg1 left a reply on Sending Emails To A User That Isn't Logged In • 1 month ago

Thanks for the help still got the same error

Connection could not be established with host smtp.mailtrap.io [Unable to find the socket transport "plain" did you forget to enable it when you configured PHP? #]

4th April, 2018

stargatesg1 left a reply on Sending Emails To A User That Isn't Logged In • 1 month ago

Thanks for all the help. I got the message going now have to fix this error in the console. I am still using Laravel 5.4

Here is my error mailtrap was working before but not sure why it isn't now

POSTXHRhttp://www.devqi.com/api/workshop[HTTP/1.1 500 Internal Server Error 2163ms] 
HeadersCookiesParamsResponseTimingsStack TraceJSONstatuserrorexceptionSwift_TransportExceptioncodeSystemErrormsgfile/www/restoredqi/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.phpline268Response payload 1{"status":"error","exception":"Swift_TransportException","code":"SystemError","msg":"Connection could not be established with host mailtrap.io [Unable to find the socket transport \"plain\" - did you forget to enable it when you configured PHP? #1]","file":"\/www\/restr\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/StreamBuffer.php","line":268}

stargatesg1 left a reply on Sending Emails To A User That Isn't Logged In • 1 month ago

Just a simple email. There is no user account associated with this address. I just like how the notification emails are done very simple. But I agree with you in Laravel has made it so complicated to send a simple email.

The simple email would just be the same as a notification template

stargatesg1 left a reply on Sending Emails To A User That Isn't Logged In • 1 month ago

The thing is I just want to send a email. The user doesn't even exist in the database and never will. So just need a easy to send a email to a user.

3rd April, 2018

stargatesg1 started a new conversation Sending Emails To A User That Isn't Logged In • 1 month ago

I was wondering if Laravel how can I send a email to a user that isn't logged in. Lets say they are registering for a workshop but doens't need a account.

Here is the code I have now but doesn't seem to be working

  $user = new User();
        $User->email='[email protected]';

        /*Send email to user */
        $user->notify(new workshop());

23rd August, 2017

stargatesg1 left a reply on Return Response As JSON • 8 months ago

This worked Thanks for the help

Route::get('/tasks/{task}', function($id) {

  $tasks=DB::table('tasks')->find($id);

    return response()->json($tasks);

});

22nd August, 2017

stargatesg1 started a new conversation Return Response As JSON • 8 months ago

I am trying to return this data as JSON but I can't remember how to do it here is the code


Route::get('/tasks/{task}', function($id) {

  $tasks=DB::table('tasks')->find($id);

  return $tasks;

});

5th August, 2017

stargatesg1 left a reply on Having Permission Issues With Upload Files And Deleting • 9 months ago

I am using OSX 10.12.6 most of the examples are in Ubuntu

I tired

sudo chmod -R 777 storage

also I tired this

sudo chown -R _www:_www storag

But didn't work also

stargatesg1 started a new conversation Having Permission Issues With Upload Files And Deleting • 9 months ago

I am hainving the following issues when use

Storage::delete() 

I get the following error

Operation not permitted

I am using apache on OSX 10.12.6

I am not sure what would be the directory permisions for app/storage and the sub directories and files are

3rd August, 2017

stargatesg1 started a new conversation Laravel Mix Configuration • 9 months ago

This is a combination of vue and laravel mix. If I have lazy loading routes the issue is that Laravel Mix doesn't put any new lazy loaded routes in a folder with the corresponding javascript file

Here is my mix file. So lets say if I add another lazy load folder how do I configure it in here. For now I ihave steps but i want to add stepsadmin.

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */


mix.webpackConfig({
    output: {
        publicPath: "/steps",
        chunkFilename: '[name].js'
    },
});


mix.js('resources/assets/js/app.js', 'public/js', {
    includePaths: ['steps','stepsadmin']
});


mix.sass('resources/assets/sass/app.scss', 'public/css', {
    includePaths: ['node_modules']
});


19th July, 2017

stargatesg1 started a new conversation Issue With Laravel Mixer With SCSS Path From Node Modules • 10 months ago

I am using material.io and when including scss from node_modules directory Laravel mixer doesn't compile. I need to include the node path for scss processing. Here has to be a way to include paths like. I should be able to compile the SCSS files with no issue.

includePaths: ['node_modules']

here is my webpack.mix.js file

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');


mix.webpackConfig({

});

stargatesg1 left a reply on Getting The Following Error This Dependency Was Not Found: FS • 10 months ago

I figured out what the issue was. The cause was I was loading vue-loader in the app.js file. Its fixed now. Thanks for the help. Late night coding wasn't thinking.

18th July, 2017

stargatesg1 started a new conversation Getting The Following Error This Dependency Was Not Found: FS • 10 months ago

When I run npm run dev. I am getting the following error

ERROR Failed to compile with 3 errors 22:07:39

This dependency was not found:

  • fs in ./node_modules/vue-loader/lib/utils/normalize.js, ./node_modules/resolve/lib/sync.js and 1 other

To install it, you can run: npm install --save fs

Here is a copy of my configuration file.

I am using Laravel 5.4

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');


mix.webpackConfig({

});

Here is my Package.json file

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "bin": {
    "cross-env": "dist/bin/cross-env.js"
  },
  "devDependencies": {
    "@websanova/vue-auth": "^2.13.0-beta",
    "axios": "^0.16.2",
    "babel": "^6.23.0",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-plugin-transform-es2015-spread": "^6.22.0",
    "babel-preset-env": "^1.6.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.0.1",
    "css-loader": "^0.28.4",
    "eslint": "^3.19.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-html": "^2.0.0",
    "eslint-plugin-import": "^2.3.0",
    "eslint-plugin-node": "^4.2.2",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^3.0.1",
    "file-loader": "^0.11.1",
    "friendly-errors-webpack-plugin": "^1.1.3",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "material-components-web": "^0.15.0",
    "material-design-icons": "^3.0.1",
    "normalize-scss": "^7.0.0",
    "path": "^0.12.7",
    "url-loader": "^0.5.8",
    "vue": "^2.4.1",
    "fs": "0.0.1-security",
    "vue-loader": "^12.2.2",
    "vue-mdc-adapter": "0.0.17",
    "vue-progressbar": "^0.7.2",
    "vue-resource": "^1.3.4",
    "vue-router": "^2.7.0",
    "webpack": "^3.2.0",
    "async": "^2.5.0",
    "normalize": "^0.3.1"
  },
  "dependencies": {

  }
}

1st June, 2017

stargatesg1 left a reply on Would Be Nice If We Had This In Laravel. • 11 months ago

Yep they compress the files like Pied Piper. Its pretty cool cheap and blazing fast.

stargatesg1 started a new conversation Would Be Nice If We Had This In Laravel. • 11 months ago

Take a look at this Amazing way to store files. Its the same thing as Pied Piper from Silicon Valley

https://storj.io/index.html

21st May, 2017

stargatesg1 left a reply on Invalid Token For Email Password Reset • 11 months ago

Thanks for all the help yep it does. Here is the error I get

{"response":{"headers":{},"original":{"message":"This password reset token is invalid."},"exception":null}}

stargatesg1 left a reply on Invalid Token For Email Password Reset • 11 months ago

So if i test it within a form without postman it also returns invalid email token

stargatesg1 left a reply on Invalid Token For Email Password Reset • 11 months ago

Don't think so it's the token assigned to the forgot password email.

When testing in postman i don't need a csfr token

stargatesg1 left a reply on Invalid Token For Email Password Reset • 11 months ago

All the routes are correct. I am just testing this in postman. When I request for a new password I get a new token and then i use that token. I can't reset the password at this point because it says invalid token

stargatesg1 started a new conversation Invalid Token For Email Password Reset • 11 months ago

I am not sure why I am getting a invalid token for password reset. I requested a reset password and the token gets inserted into the database but when I test that token using postman it comes up as invalid. Here is the custom code I basically took some of the code from

Illuminate\Foundation\Auth\ResetsPasswords

Here is the code

<?php

namespace App\Http\Controllers\Api;


namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\PasswordBroker;
use Response;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Password;

//Trait
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPassController extends Controller
{

    use ResetsPasswords;


    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function resetpass(Request $request)
    {
        $respond=$this->reset($request);

        return response([
            'response' => $respond
        ]);
    }


    public function rules()
    {
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:6',
        ];
    }


    public function reset(Request $request)
    {
        //$this->validate($request, $this->rules(), $this->validationErrorMessages());

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
            $this->resetPassword($user, $password);
        }
        );

        // If the password was successfully reset, we will redirect the user back to
        // the application's home authenticated view. If there is an error we can
        // redirect them back to where they came from with their error message.
        $response == Password::PASSWORD_RESET
            ? $this->sendResetResponse($response)
            : $this->sendResetFailedResponse($request, $response);
        return response(['message' => trans($response)]);

    }

    public function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => bcrypt($password),
            'remember_token' => Str::random(60),
        ])->save();

    }


    public function credentials(Request $request)
    {
        return $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );
    }

}

6th April, 2017

stargatesg1 started a new conversation Selecting Date Field • 1 year ago

I am having problems selecting a date field. Lets say created_at has the value of

"created_at": "2017-04-01 14:27:36" I want to write a Eloquent statement like this

        $getCurrent=$Usage->where([
            ['track_id', '=', 16],
            ['user_id', '=', 1],
            ['created_at', '=', date('Y-m-d')]
        ])->get();

So in the created_at it will select the current date minus the time.

14th March, 2017

stargatesg1 left a reply on Enable Hotlinking • 1 year ago

Thanks for the help. I tried that and it didn't work I can still access my images form jsfiddle. Here is the updated configuration.

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/mydomain.com/before/*;

server {
    listen 80;
    listen [::]:80;
    server_name mydomain.com;
    root /home/forge/mydomain.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers '';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/mydomain.com/server/*;

   location / {
       try_files $uri $uri/ /index.php?$query_string;
}
    
    
    

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/mydomain.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }
    


location ~ .(gif|png|jpe?g)$ {
    valid_referers blocked mydomain.com www.mydomain.com;
    if ($invalid_referer) {
        return 403;
    }
}




## Deny certain Referers (case insensitive)
    ## The ~* makes it case insensitive as opposed to just a ~
 if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo))
    {  return 403;   }
    



location ~ /\.ht {
    deny all;
}



}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/mydomain.com/after/*;

stargatesg1 left a reply on Disable Hotlinking • 1 year ago

Can anybody shine some light on this?

9th March, 2017

stargatesg1 started a new conversation Disable Hotlinking • 1 year ago

In my nginx configuration I am having trouble enabling hotlinking protection. I don't want other sites accessing images from my server. Here is my configuration file. I am not sure what i am doing wrong.

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/mydomain.com/before/*;

server {
    listen 80;
    listen [::]:80;
    server_name mydomain.com;
    root /home/forge/mydomain.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
       ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/mydomain.com/server/*;

   location / {
       try_files $uri $uri/ /index.php?$query_string;
}
    
    
    

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/mydomain.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }
    
    #Prevent hotlinking
location ~* (\.jpg|\.png|\.css|\.mp3)$ {
    valid_referers blocked mydomain.com www.mydomain.com;
    if ($invalid_referer) {
        return 444;
    }
}


    location ~ /\.ht {
        deny all;
    }
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/mydomain.com/after/*;

18th February, 2017

stargatesg1 started a new conversation Trial For Different Subscriptions • 1 year ago

In Laravel Cashier how do you set up trials for different packages.

Let's say package one costs $9.99

and package two

10.99

how can i set trial options for different packages is it built in Laravel

15th February, 2017

stargatesg1 started a new conversation 500 Internal Server Error On Forge Using Ngingx • 1 year ago

I am having a issue. On my local apache machine everything works the token returns the error codes with no problem and returns the proper headers. On the live machine I get a 500 internal server error. Here is the issue on github can't seem to solve it

https://github.com/tymondesigns/jwt-auth/issues/1006

There is also a log as to what is happening on the server.

stargatesg1 left a reply on Exception Error • 1 year ago

Thanks that fixed the issue

14th February, 2017

stargatesg1 started a new conversation Exception Error • 1 year ago

I am getting the following error. I am still using Laravel 5.3. Not sure what I am missing here.

{"status":"error","exception":"ErrorException","code":"SystemError","msg":"Declaration of App\\Providers\\EventServiceProvider::boot(Illuminate\\Contracts\\Events\\Dispatcher $events) should be compatible with Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider::boot()","file":"\/www\/restoredqi\/app\/Providers\/EventServiceProvider.php","line":11}

EventServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\SomeEvent' => [
            'App\Listeners\EventListener',
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot(DispatcherContract $events)
    {
        parent::boot($events);


        // fired when the token could not be found in the request
        Event::listen('tymon.jwt.absent', function () {
            throw new \App\Exceptions\JWTAbsentException;
        });

        // fired when the token has expired
        Event::listen('tymon.jwt.expired', function () {
            throw new \App\Exceptions\JWTExpiredException;
        });

        // fired when the token is found to be invalid
        Event::listen('tymon.jwt.invalid', function () {
            throw new \App\Exceptions\JWTInvalidException;
        });

        // fired if the user could not be found (shouldn't really happen)
        Event::listen('tymon.jwt.user_not_found', function () {
            throw new \App\Exceptions\JWTUserNotFoundException;
        });
    }
}

Handler.php

<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;



class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        AuthorizationException::class,
        HttpException::class,
        ModelNotFoundException::class,
        ValidationException::class,
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $exception
     * @return void
     */
    public function report(Exception $exception)
    {
        parent::report($exception);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $e
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        }

        $class = get_class($e);

        switch($class) {
            case 'Illuminate\\Http\\Exception\\HttpResponseException':
                return parent::render($request, $e);
                break;
            case 'Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException':
                $code = 'NotFound';
                $msg = 'Not Found.';
                $statusCode = 404;
                break;
            case 'Illuminate\Database\Eloquent\ModelNotFoundException':
                $code = 'ModelNotFound';
                $model = str_replace('App\\Models\\', '', $e->getModel());
                $msg = $model . ' not found.';
                $statusCode = 404;
                break;
            case 'Illuminate\Auth\Access\AuthorizationException':
                $code = 'InvalidCredentials';
                $msg = 'Credentials are invalid.';
                $statusCode = 400;
                break;
            case 'Tymon\JWTAuth\Exceptions\JWTException';
                $code = 'JWTException';
                $msg = 'There was an issue generating jwt tokens.';
                $statusCode = 400;
                break;
            case 'App\Exceptions\JWTAbsentException';
                $code = 'TokenAbsent';
                $msg = 'The token is absent.';
                $statusCode = 400;
                break;
            case 'App\Exceptions\JWTExpiredException';
                $code = 'TokenExpired';
                $msg = 'The token has expired.';
                $statusCode = 401;
                break;
            case 'App\Exceptions\JWTInvalidException';
                $code = 'InvalidToken';
                $msg = 'The token is invalid.';
                $statusCode = 401;
                break;
            case 'App\Exceptions\JWTUserNotFoundException';
                $code = 'UserNotFound';
                $msg = 'The user token does not match.';
                $statusCode = 404;
                break;
            default:
                $code = 'SystemError';
                $msg = $e->getMessage();
                $file = $e->getFile();
                $line = $e->getLine();
                $statusCode = 500;
        }

        $data = [
            'status' => 'error',
            'exception' => $class,
            'code' => $code,
            'msg' =>  $msg
        ];

        if (isset($file)) {
            $data['file'] = $file;
        }

        if (isset($line)) {
            $data['line'] = $line;
        }

        return response($data, $statusCode)
            ->header('Access-Control-Allow-Origin', '*')
            ->header('Access-Control-Allow-Headers', 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With')
            ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
    }

    /**
     * Convert an authentication exception into an unauthenticated response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Illuminate\Auth\AuthenticationException  $exception
     * @return \Illuminate\Http\Response
     */
    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->guest('login');
    }
}

28th January, 2017

stargatesg1 left a reply on Pulling Mp3 File From Storage • 1 year ago

It works on every browser except safari it thinks its a stream

stargatesg1 left a reply on Pulling Mp3 File From Storage • 1 year ago

Works in all browsers except safari. If I put a mp3 file in public it works but storage doesn't thinks its a stream

stargatesg1 left a reply on Pulling Mp3 File From Storage • 1 year ago

The file is being pulled from storage. I tried this doesn't work

 $file=Storage::disk('local')->get('tracks/'.$path.'/'.$audio);
        $fileName='tracks/'.$path.'/'.$audio;
        $filesize = Storage::disk('local')->size($fileName);


       // return response($file, 200)->header('Content-Type', $mime_type);

        $size   = $filesize; // File size
        $length = $size;           // Content length
        $start  = 0;               // Start byte
        $end    = $size - 1;       // End byte

$headersArray=[
            'Accept-Ranges' => "bytes",
            'Accept-Encoding' => "gzip, deflate",
            'Pragma' => 'public',
            'Expires' => '0',
            'Cache-Control' => 'must-revalidate',
            'Content-Transfer-Encoding' => 'binary',
            'Content-Disposition' => ' inline; filename='.$audio,
            'Content-Length' => $filesize,
            'Content-Type' => "audio/mpeg",
            'Connection' => "Keep-Alive",
            'Content-Range' => 'bytes 0-'.$end .'/'.$size,
            'X-Pad' => 'avoid browser bug',
            'Etag' => $audio,
        ];

        return response()->file($fileName, $headersArray);

stargatesg1 started a new conversation Pulling Mp3 File From Storage • 1 year ago

For some reason when pulling a mp3 file from storage only safari reads it as brodcast. Not sure why here is my controller code

Controller

 /*Return trackAudio */
    public function getTrackAudio($audio){

        $track = Tracks::where('audio', $audio)->first();


        $audio=$track->audio;
        $trackCat=$track->trackcat_ID;



        switch ($trackCat) {
            case 1:
                $path="muti";
                break;

            case 2:
                $path="over";
                break;

            case 3:
                $path="pra";
                break;

            default:
                $path="muti";
        }


        $file=Storage::disk('local')->get('tracks/'.$path.'/'.$audio);
        $fileName='tracks/'.$path.'/'.$audio;
        $filesize = Storage::disk('local')->size($fileName);


       // return response($file, 200)->header('Content-Type', $mime_type);

        $size   = $filesize; // File size
        $length = $size;           // Content length
        $start  = 0;               // Start byte
        $end    = $size - 1;       // End byte

        return response($file)
            ->withHeaders([
                'Accept-Ranges' => "bytes",
                'Accept-Encoding' => "gzip, deflate",
                'Pragma' => 'public',
                'Expires' => '0',
                'Cache-Control' => 'must-revalidate',
                'Content-Transfer-Encoding' => 'binary',
                'Content-Disposition' => ' inline; filename='.$audio,
                'Content-Length' => $filesize,
                'Content-Type' => "audio/mpeg",
                'Connection' => "Keep-Alive",
                'Content-Range' => 'bytes 0-'.$end .'/'.$size,
                'X-Pad' => 'avoid browser bug',
                'Etag' => $audio,
            ]);



    }

Route

Route::get('user/track/audio/{audio}',[
    'uses' => '[email protected]',
]);

24th January, 2017

stargatesg1 left a reply on Email Not Sending When Called • 1 year ago

I think i figured it out.

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class emailactivate extends Mailable
{

    public $actLink;

    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */

    public function __construct($actLink)
    {
        $this->actLink = $actLink;
    }


    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->from('[email protected]')->view('auth.activate.php');
    }
}

stargatesg1 left a reply on Email Not Sending When Called • 1 year ago

Thanks for the help so it would change to this

public function sendActivationMail($user)
{

    if ($user->activated || !$this->shouldSend($user)) {
        return;
    }

    $token = $this->activationRepo->createActivation($user);
    $link = route('usractivate', $token);
    Mail::to($user)->send(new MailableObject($link));

}

Email Activation Class

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class emailactivate extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */

    public function __construct($actLink)
    {
        $actLink;
    }


    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->from('[email protected]')->view('auth.activate.php');
    }
}

23rd January, 2017

stargatesg1 started a new conversation Email Not Sending When Called • 1 year ago

When I call sendActivationMail. It doesn't send the email. I not too sure as to why.

ActivationService

<?php

namespace App;


use Illuminate\Mail\Mailer;
use Illuminate\Mail\Message;

class ActivationService
{

    protected $mailer;

    protected $activationRepo;

    protected $resendAfter = 24;

    public function __construct(Mailer $mailer, ActivationRepository $activationRepo)
    {
        $this->mailer = $mailer;
        $this->activationRepo = $activationRepo;
    }

    public function sendActivationMail($user)
    {

        if ($user->activated || !$this->shouldSend($user)) {
            return;
        }

        $token = $this->activationRepo->createActivation($user);

        $link = route('usractivate', $token);
        $message = sprintf('Activate account <a href="%s">%s</a>', $link, $link);

        $this->mailer->raw($message, function (Message $m) use ($user) {
            $m->to($user->email)->subject('Activation mail');
        });



    }

    public function activateUser($token)
    {
        $activation = $this->activationRepo->getActivationByToken($token);

        if ($activation === null) {
            return null;
        }

        $user = User::find($activation->user_id);

        $user->activated = true;

        $user->save();

        $this->activationRepo->deleteActivation($token);

        return $user;

    }

    private function shouldSend($user)
    {
        $activation = $this->activationRepo->getActivation($user);
        return $activation === null || strtotime($activation->created_at) + 60 * 60 * $this->resendAfter < time();
    }

}

11th January, 2017

stargatesg1 left a reply on QR Code Generator • 1 year ago

A lot of that generates PDFs with the content in it. I am looking for something that generates the image QR code.

stargatesg1 started a new conversation QR Code Generator • 1 year ago

I was wondering if there is a laravel library to generate QR Codes?

stargatesg1 left a reply on HTML Not Found • 1 year ago

Thanks for all the help. I decided to use the following

URL::asset()

10th January, 2017

stargatesg1 started a new conversation HTML Not Found • 1 year ago

For some reason I am getting the following error

HTML not found

The reson for this is the following code

 <link href="{{ HTML::image('favicon/favicon.jpg') }}" rel="apple-touch-icon"  />

I am not sure why. I think I need to add a provider in config/app.php but not sure what.

3rd January, 2017

stargatesg1 left a reply on Reset Password Controller • 1 year ago

So I figured it out. Problem it was redirecting to views. here is the updated code

<?php

namespace App\Http\Controllers\Api;

use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Support\Facades\Password;

use Illuminate\Support\Facades\Log;

class ResetPassController extends Controller
{


    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function reset(Request $request)
    {
        //$this->validate($request, $this->rules(), $this->validationErrorMessages());

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
            $this->resetPassword($user, $password);
        }
        );

        // If the password was successfully reset, we will redirect the user back to
        // the application's home authenticated view. If there is an error we can
        // redirect them back to where they came from with their error message.
        return $response == Password::PASSWORD_RESET
            ? $this->sendResetResponse($response)
            : $this->sendResetFailedResponse($request, $response);
    }

    /**
     * Get the password reset validation rules.
     *
     * @return array
     */
    protected function rules()
    {
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:6',
        ];
    }

    /**
     * Get the password reset validation error messages.
     *
     * @return array
     */
    protected function validationErrorMessages()
    {
        return [];
    }

    /**
     * Get the password reset credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(Request $request)
    {
        return $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );
    }

    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @param  string  $password
     * @return void
     */
    protected function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => bcrypt($password),
            'remember_token' => Str::random(60),
        ])->save();

        $this->guard()->login($user);
    }

    /**
     * Get the response for a successful password reset.
     *
     * @param  string  $response
     * @return \Illuminate\Http\Response
     */
    protected function sendResetResponse($response)
    {
        return trans($response);
    }

    /**
     * Get the response for a failed password reset.
     *
     * @param  \Illuminate\Http\Request
     * @param  string  $response
     * @return \Illuminate\Http\RedirectResponse
     */
    protected function sendResetFailedResponse(Request $request, $response)
    {
        return ['email' => trans($response)];
    }

    /**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        return Password::broker();
    }

    /**
     * Get the guard to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\StatefulGuard
     */
    protected function guard()
    {
        return Auth::guard();
    }




}

2nd January, 2017

stargatesg1 started a new conversation Reset Password Controller • 1 year ago

For some reason when i call the following route it doesn't reset the password. Here is the code

Route

Route::post('eml/pass/reset',[
        'uses' => '[email protected]'
    ]);

#Controller

<?php

namespace App\Http\Controllers\Api;

use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Support\Facades\Password;

class ResetPasswordController extends Controller
{


    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function reset(Request $request)
    {
        //$this->validate($request, $this->rules(), $this->validationErrorMessages());

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
            $this->resetPassword($user, $password);
        }
        );

        // If the password was successfully reset, we will redirect the user back to
        // the application's home authenticated view. If there is an error we can
        // redirect them back to where they came from with their error message.
        return $response == Password::PASSWORD_RESET
            ? $this->sendResetResponse($response)
            : $this->sendResetFailedResponse($request, $response);
    }

    /**
     * Get the password reset validation rules.
     *
     * @return array
     */
    protected function rules()
    {
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:6',
        ];
    }

    /**
     * Get the password reset validation error messages.
     *
     * @return array
     */
    protected function validationErrorMessages()
    {
        return [];
    }

    /**
     * Get the password reset credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(Request $request)
    {
        return $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );
    }

    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @param  string  $password
     * @return void
     */
    protected function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => bcrypt($password),
            'remember_token' => Str::random(60),
        ])->save();

        $this->guard()->login($user);
    }

    /**
     * Get the response for a successful password reset.
     *
     * @param  string  $response
     * @return \Illuminate\Http\Response
     */
    protected function sendResetResponse($response)
    {
        return redirect($this->redirectPath())
            ->with('status', trans($response));
    }

    /**
     * Get the response for a failed password reset.
     *
     * @param  \Illuminate\Http\Request
     * @param  string  $response
     * @return \Illuminate\Http\RedirectResponse
     */
    protected function sendResetFailedResponse(Request $request, $response)
    {
        return redirect()->back()
            ->withInput($request->only('email'))
            ->withErrors(['email' => trans($response)]);
    }

    /**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        return Password::broker();
    }

    /**
     * Get the guard to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\StatefulGuard
     */
    protected function guard()
    {
        return Auth::guard();
    }
}

30th December, 2016

stargatesg1 started a new conversation Controller Not Sending Emails • 1 year ago

So I modified the sendResetLinkEmail controller but when I call the controller it doesn't work at all

Here is my route.

    /* Reset Email */
    Route::post('eml/pass',[
        'uses' => '[email protected]'
    ]);
<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\PasswordBroker;
use Response;
use App\Http\Requests;
use App\Http\Controllers\Controller;


class ForgotPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset emails and
    | includes a trait which assists in sending these notifications from
    | your application to your users. Feel free to explore this trait.
    |
    */

    //use SendsPasswordResetEmails;


    /**
     * Send a reset link to the given user.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function sendResetLinkEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );



        // If an error was returned by the password broker, we will get this message
        // translated so we can notify a user of the problem. We'll redirect back
        // to where the users came from so they can attempt this process again.
        return $response;
    }

    /**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        return Password::broker();
    }


    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }
}

29th December, 2016

stargatesg1 started a new conversation Reset Email Link • 1 year ago

I am having trouble trying to get the following route working in Laravel with Vuejs

Route::post('password/email', 'Auth\[email protected]');

But the problem with that route is it redirects the whole page it isn't part of a API.

Here is my vueJS code


methods: {

        forgotpassword: function(user){

            var _this=this;
            var frmtkn=document.querySelector('#token').getAttribute('content');

            this.$http.post('api/users/list', {"X-CSRF-TOKEN": frmtkn}).then(response => response.json()).then((data) => {

            }).catch((response) => { console.error(response); });


        }

    }

27th December, 2016

stargatesg1 started a new conversation Reset Email Customize Template For Branding • 1 year ago

I am trying to wrap my head around the following how do I customize the email notification for branding? Also when resetting a password I create a form with a field called email and call this route?

Route::post('password/email', 'Auth\[email protected]');

This will request the users email address and send the reset link? How can I customize the reset link.

This route what paramaters are required?

Route::post('password/reset', 'Auth\[email protected]');

The Reason for all of this is because all of my views are vuejs views.

25th December, 2016

stargatesg1 left a reply on Forgot Password Routes • 1 year ago

So what do i define in my routes/api.php. What is $this-> defined as?

stargatesg1 left a reply on Forgot Password Routes • 1 year ago

Does Auth::routes(); Consist of the following

// Authentication Routes...
    Route::get('login', 'Auth\[email protected]')->name('login');
    Route::post('login', 'Auth\[email protected]');
    Route::post('logout', 'Auth\[email protected]');

    // Registration Routes...
    Route::get('register', 'Auth\[email protected]');
    Route::post('register', 'Auth\[email protected]');

    // Password Reset Routes...
    Route::get('password/reset', 'Auth\[email protected]');
    Route::post('password/email', 'Auth\[email protected]');
    Route::get('password/reset/{token}', 'Auth\[email protected]');
    Route::post('password/reset', 'Auth\[email protected]');

stargatesg1 started a new conversation Forgot Password Routes • 1 year ago

So In Laravel I am noticing the following in the routes

Auth::routes();

But the question is what is the exact routes being called to forgot password. Reason being is that I am using jwt auth. I just need a forgot password route so i can call them within my vue front-end and pass the users email.

24th December, 2016

stargatesg1 started a new conversation Error The Response Content Must Be A String Or Object • 1 year ago

For some reason when i call this route. Like this http://snd.com/sound/23

I get the following error

UnexpectedValueException in Response.php line 403: The Response content must be a string or object implementing __toString(), "object" given.

I am not sure what I am missing

Route

Route::get('sound/{id}',[
        'uses' => '[email protected]'
    ]);
    /*Return trackAudio */
    public function getsound(Tracks $track){
        $audio=$track->audio;
        $trackCat=$track->trackcat_ID;
        $mime_type = "audio/x-mpegurl";


        $path="trk";


        $file=Storage::disk('local')->get('tracks/'.$path.'/'.$audio);
        $filesize = Storage::disk('local')->size($file);

        $headers = [
            'Content-Description' => 'File Transfer',
            'Content-Type' =>$mime_type,
            'Content-Disposition' => "attachment; filename*=UTF-8''".asset(''),
            'Content-Length' => $filesize,
            'Pragma' => 'public',
            'Cache-Control' => 'must-revalidate',
            'Expires' => '0',
        ];


        return (new Response($file, 200, $headers));

    }
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.