arthvrian

arthvrian

Member Since 1 Month Ago

Experience Points 4,420
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 7
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

10 Dec
6 days ago

arthvrian left a reply on PHP Query

short answer: in PHP you MUST define a variable BEFORE use it long answer: before run a SQL query, you MUST validate, sanitise and secure your input (local or user input), another link to read :P https://www.dreamhost.com/blog/php-security-user-validation-sanitization/

18 Nov
4 weeks ago

arthvrian left a reply on Changing The Heading In Forgot Password

  1. php artisan vendor:publish and select laravel-mail tag (I'm not sure)
  2. Edit resources/views/vendor/mail/html/header.blade.php

Note: All mails share the same structure

17 Nov
4 weeks ago

arthvrian left a reply on How To Hit The Api Route

try php artisan route:list, check for api routes

12 Nov
1 month ago

arthvrian left a reply on Laravel Where('user_id') Seems Completely Ignored

OR WHERE invalidate the previous WHERE, query result:

SELECT * FROM Pigeon WHERE user_id =? AND name LIKE '%?%' OR ringnumber LIKE '%?%'

You can do someting like:

User::pigeons()->where('name', 'LIKE', '%'.$q.'%')->orWhere('ringnumber','LIKE','%'.$q.'%')

arthvrian left a reply on Why Did Not Save Multiple Images With Controller Route Return?

nope

for (....)
            $upload->save();
}
            
return redirect()->route('categories.categorypost')->with('info','Your Advertisment has been created successfully');
        

arthvrian left a reply on Why Did Not Save Multiple Images With Controller Route Return?

You must close the for BEFORE the return (i don't see the })

10 Nov
1 month ago

arthvrian left a reply on Google Gmail SMTP

Is this domain hjorturfreyr.com using GSuite?

Yo cann't send a email throught gmail without a google accout (Gmail/GSuite)

[email protected] // must be a Google Account

arthvrian left a reply on Why Is Php Artisan Serve Not Working Anymore?

Maybe you 'kill' MySQL too

it seems that your MySQL server is down or running on another port

arthvrian left a reply on All Problems With The New Laracasts Design

@JEFFREYWAY - thanks, maked as fixed :D

arthvrian left a reply on How To Pull User-specific Data From Database After User Login.

No, In your LoginController not, I assume that the view in first post shows after login, you must put the code in the controller of that view

or you can try in your view

Hi Auth::user()->name. Welcome to your dashboard.

arthvrian left a reply on How To Pull User-specific Data From Database After User Login.

If you use laravel auth, you can put this in your controller:

// Get the currently authenticated user...
$user = Auth::user();

and in your view:

Hi $user->name. Welcome to your dashboard.

arthvrian left a reply on Migration Error On Laravel 5.7

It seems that your MySQL server is down or running on another port try to verify through command line or mysql client if you can connect

09 Nov
1 month ago

arthvrian left a reply on Laravel Method Delete Ajax Request

And the error is?

in the AJAX function? did you see the console? in the response? did you check if the method receive the id, the id exists, etc?

arthvrian left a reply on All Problems With The New Laracasts Design

@jeffreyway if the last answer of a conversation/thread is in page 2+ the link on the thread list not work (sends to first post) I think is because with infinity scroll not load that answer yet

infinity scroll behaviour in long conversations/threads this is annoying

08 Nov
1 month ago

arthvrian left a reply on Page Loads But In Network Gets 404

as @snapey said:

put your files outside your public folder www

right now you can go to

http://engenhariamrc.com.br/admin/login -> 404 http://engenhariamrc.com.br/public/admin/login -> 200

Upon entering www, www/.htaccess 'process' the request and sends it to www/public/.htaccess which sends it to www/public/index.php, which processes the request

try removing/renaming www/.htaccess and hit the two links before (first one must be not working anymore)

07 Nov
1 month ago

arthvrian left a reply on Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

did you put that file

bootstrap.min.js.map NOT bootstrap.min.js

in the same folder?

arthvrian left a reply on Display Form Errors Only Within A Certain Form

From the docs https://laravel.com/docs/5.7/validation

Named Error Bags If you have multiple forms on a single page, you may wish to name the MessageBag of errors, allowing you to retrieve the error messages for a specific form. Pass a name as the second argument to withErrors:

return redirect('register')
            ->withErrors($validator, 'login');

You may then access the named MessageBag instance from the $errors variable:

{{ $errors->login->first('email') }}

arthvrian started a new conversation All Problems With The New Laracasts Design

Is not it better to have them in one place? Some I've seen (threads) (only from page one :P)

any other?

Some that I have seen

  • When you answer the avatar is not show (can be error with the link to gravatar in my case) until you reload the page
  • If the answer is too long, it can not be published, the lower buttons of the modal disappear

arthvrian left a reply on New Design. Is Pagination Missing On Long Discussion Threads?

It is right i.e. https://laracasts.com/discuss/channels/general-discussion/where-are-you-all-from

@JeffreyWay ...

seems like infinity scroll pagination?

there is a error on javascript (loading page 2 from http NOT https)

all.min.js?v=220:5 Mixed Content: The page at 'https://laracasts.com/discuss/channels/general-discussion/where-are-you-all-from' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://laracasts.com/discuss/channels/general-discussion/where-are-you-all-from?page=2&ajax=1'. This request has been blocked; the content must be served over HTTPS.
(anonymous) @ all.min.js?v=220:5
t.exports @ all.min.js?v=220:5
t.exports @ all.min.js?v=220:10
Promise.then (async)
i.request @ all.min.js?v=220:10
i.(anonymous function) @ all.min.js?v=220:10
(anonymous) @ all.min.js?v=220:5
fetchReplies @ all.min.js?v=220:17
(anonymous) @ all.min.js?v=220:17
c @ all.min.js?v=220:18
f @ all.min.js?v=220:18
u @ all.min.js?v=220:18
setTimeout (async)
u @ all.min.js?v=220:18
setTimeout (async)
u @ all.min.js?v=220:18
setTimeout (async)
h @ all.min.js?v=220:18
all.min.js?v=220:5 Uncaught (in promise) Error: Network Error
    at t.exports (all.min.js?v=220:5)
    at XMLHttpRequest.d.onerror (all.min.js?v=220:5)```
05 Nov
1 month ago

arthvrian left a reply on Get Data From Two Tables

without your data structure, is a little hard

did you try dump($results) or dump($project) in your view? to see if you get any data or what data you get

// from the previous link
$books = App\Book::with('author')->get();

foreach ($books as $book) {
    echo $book->author->name;
}

// you can do something like (set according to your view/table)

foreach ($results as $project) {
    echo $project->user->id; // get the user id of the project
}

arthvrian left a reply on Get Data From Two Tables

first of all, you can read this https://laravel.com/docs/5.7/eloquent-relationships

if any further question, write here :D

arthvrian left a reply on How To Make An Multiple Unique Index With A Special Value?

I think he means:

|-------------|--------------------|--------| |user|username|active| |Jhon Doe|jhon1@email.tld|1| |Jhon Doe|jhon2@email.tld|0| |-------------|--------------------|--------|

Jhon have N users but only one active

is correct? @alihoushyaripour

arthvrian left a reply on Class App\Http\Middleware\CheckRole Does Not Exist

@dokunbam , incorrect :P

Role.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    //
    public function users()  // NOT roles()
    {
        return $this
            ->belongsToMany('App\User')
            ->withTimestamps();
    }
}

User.php


namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function roles()  // NOT users()
    {
        return $this
            ->belongsToMany('App\Role')
            ->withTimestamps();
    }

    public function authorizeRoles($roles)
    {
        if ($this->hasAnyRole($roles)) {
            return true;
    }
    abort(401, 'This action is unauthorized.');
    }
     
    public function hasAnyRole($roles)
    {
        if (is_array($roles)) {
            foreach ($roles as $role) {
                if ($this->hasRole($role)) {
                    return true;
                }
            }
    } else {
        if ($this->hasRole($roles)) {
            return true;
          }
        }
        return false;
    }
    public function hasRole($role)
    {
        if ($this->roles()->where(‘name’, $role)->first()) {
            return true;
        }
        return false;
    }

}

arthvrian left a reply on Class App\Http\Middleware\CheckRole Does Not Exist

from the link

Add roles() method to your User.php class

your call this method users()in your User.php

03 Nov
1 month ago

arthvrian left a reply on Manage Different View Cards Or List

with database option, also works in case of multi device or different browsers

arthvrian left a reply on Change Login/Register Redirect Path

did you check the middleware? (app\Http\Middleware\RedirectIfAuthenticated.php)

    if (Auth::guard($guard)->check()) {
            return redirect('/home');
        }
02 Nov
1 month ago

arthvrian left a reply on Email Settings

MAIL_DRIVER=smtp
MAIL_HOST=secure251.inmotionhosting.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
[email protected]
MAIL_FROM_NAME=Your name

arthvrian left a reply on Simple Profile Update Persisting Data

do you mean sometihing like

if ($validator->fails()) {
            $messages = $validator->errors();
            return back()
                        ->withErrors($messages)
                        ->withInput();
        }

and in the view

<input type="text" name="username" value="{{ old('name') }}">
31 Oct
1 month ago

arthvrian left a reply on How Do I Pass Users Id To The Modal?

@sucoms if you know your admin_id (and it never change) you can do it by replace it in the form action

let admin_id = ? // may be constant?
let user_id = ? // as @Borisu sugest
let newAction = $('.modal-footer').find('form').attr('action'); // did not find form name/id

newAction = newAction.replace(admin_id, user_id);

$('.modal-footer').find('form').attr('action', newAction);

if the admin_id varies (or you have more that one) is a little bit diferent

30 Oct
1 month ago

arthvrian left a reply on How Do I Pass Users Id To The Modal?

you have your user_id here

<td><button type="button" class="remove-button btn btn-danger" data-id="'.$row->id.'">

correct?

and you open your modal with a form with your admin_id

 {{ Form::open(['action'=> ['[email protected]', Auth::user()->id],'method' => 'POST']) }}

correct?

you must find (via javascript) the way to replace your admin_id with your user_id in the form action, before show the modal

arthvrian left a reply on How To Fix **Swift_TransportException** In Laravel 5.6

@Flex, are you using TLS? with what port? according to gmail help

you must use TLS with port 587

or

you must use SSL with port 465

you can not mix port numbers (see my previous answer)

arthvrian left a reply on Change Input, Based On Select:option

You must use select2 events https://select2.org/programmatic-control/events

$('#myselect').on('select2:select', function (e) {
    var data = e.params.data;
    console.log(data);
    // @lostdreamer_nl change function here
});
29 Oct
1 month ago

arthvrian left a reply on Can't Delete Items From Cart, Only Quantity And Leaving The Item With 0 Quantity

@AndreLan in the view you only show orders with qty > 0?

if is true, this is useles

@elseif ($order->qty > 1) //must be only @else

I would name the second method diferently, perhaps update_order or update_order_qty

You can extract the product update to a separated method, to avoid repeating the code

Last 3 lines on cancel_qty will never be executed

arthvrian left a reply on How To Remove Login Redirection Route

i don't follow you

you mean AFTER login do not redirect to /home?

arthvrian left a reply on Pass Data To Form On Another Page

one approach

GET test.com/scripts/34/prescription/create

(fails on condition two, easily manipulated)

other approach

POST test.com/scripts/34/prescription or test.com/scripts/34

then save script id to a cookie/session then redirect to

test.com/prescriptions/create

arthvrian left a reply on POST Https://api.stripe.com/v1/tokens 402

@asad98iftikhar that is the response?

docs examples says must be like:

{
  error: {
    type: "card_error", // Type of error
    code: "invalid_expiry_year", // Optional identifier of specific error
    message: "Your card's expiration year is invalid.", // Description of the error
    param: "exp_year" // Optional identifier of the offending parameter
  }
}

also, as I can see ** Stripe.card.createToken($form, stripeResponseHandler);** is deprecated too https://stripe.com/docs/stripe-js/v2

arthvrian left a reply on POST Https://api.stripe.com/v1/tokens 402

according to the docs https://stripe.com/docs/api/errors

402 - Request Failed The parameters were valid but the request failed.

can you post all the response?

arthvrian left a reply on Can't Delete Items From Cart, Only Quantity And Leaving The Item With 0 Quantity

  1. You can control a number in HTML with min/max attributes of an input
<input type="number" name="quantity" min="1" max="5">

or via javascript, before submit the form (early check)

  1. common approach is one button to delete the item and one form to change the item quantity, of course you can check
if **$order->qty** == 1 submit change form (with input 'quantity' = 1)  else show popup ...

on the view, with a single button

  1. this is useless (unless you want to delete more that 255 items)
if ($request->input('qty') > $order->qty) {
            return redirect('/my_cart')
                        ->withErrors($validator)
                        ->withInput();
        }

validator return no error if $request->input('qty') < 255, result in a redirect without feedback to user, you can modify

$validator = Validator::make($request->all(), [
            'qty' => 'required|max:'.$order->qty,  // you can check min too
            
        ]);

as a post check

  1. if you can reach here, check if $order->qty == 1, delete the order, etc and redirect

  2. if you can reach here, means $order->qty > 1, update order, update stock, etc and redirect

arthvrian left a reply on Missing Required Parameters For [Route: ... ] [URI: ... ]

@thomaskim is right, but whit his approach you end with a route like this

data-href="http://localhost:8000/cart/update/Diesel-DZ4447/3"

next time, one like this

data-href="http://localhost:8000/cart/update/Diesel-DZ4447/15"

as you want to do is update the quantity of products, you can pass a static second parameter like '0' or ':quantity' to the route helper, easily replaceable by javascript

in the other hand, I'm not fan of this kind of approach, consider POST (via form or AJAX) as @Snapey said

arthvrian left a reply on How To Fix **Swift_TransportException** In Laravel 5.6

from gmail help:

https://support.google.com/mail/answer/7126229?hl=en

TLS

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

SSL

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl