FallOutBoi

FallOutBoi

Member Since 3 Weeks Ago

Experience Points 980
Experience Level 1

4,020 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

18 Jul
4 days ago

FallOutBoi left a reply on Model Relationship Returns Error

So wishlists belongs to many users and products?

FallOutBoi left a reply on Model Relationship Returns Error

Now it says

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'products.wishlist_id

Whut?

FallOutBoi started a new conversation Model Relationship Returns Error

Hi, i have Product and Wishlist models. I have connected them with relationship but when i try to get all products for that wishlist it returns this

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'products.wishlist_id' in 'where clause' (SQL: select * from `products` where `products`.`wishlist_id` = 88 and `products`.`wishlist_id` is not null) 

Here's my models

Product.php 

 public function wishlist()
 {
      return $this->belongsToMany(Wishlist::class); 
 }
Wishlist.php

public function products()
{
    return $this->hasMany(Product::class);
}

The database table for wishlists looks like this

id  user_id product_id  created_at  updated_at

I tried to change wishlist products method to belongsTo instead of belongsToMany but still the same thing.

17 Jul
5 days ago

FallOutBoi left a reply on Checking If Relation Exists In Blade

Yeah got it fixed by @mstrauss 's many to many relationship code

FallOutBoi left a reply on Checking If Relation Exists In Blade

Yes i did, thank you but i need to change the icons on blade accoring to relation. When i use

@if( $product->check())
   <i class="far fa-heart icon" id="{{$product->id}}"></i>
@else
  <i class="fas fa-heart icon" id="{{$product->id}}"></i>
@endif

Icons are the same

FallOutBoi left a reply on Checking If Relation Exists In Blade

$auth?? did you mean Auth::user()->itemOnWishlist($product->id) ????

FallOutBoi left a reply on Checking If Relation Exists In Blade

The first one keeps the same icon on all products, the second one says 'Method name must be a string'.

FallOutBoi started a new conversation Checking If Relation Exists In Blade

Hi, i am trying to show different icon when user has specific item in wishlist but it doesnt work. I have relations set up like so

Product.php 

    public function wishlist()
    {
        return $this->belongsTo(Wishlist::class);
    }


    public function check($id)
    {
        return optional($this->wishlist()->select('product_id')->where('product_id', '=', $id)->first())->product_id;
    }
Wishlist.php 

    public function products()
    {
        return $this->hasMany(App\Product);
    }

Whenever i call check() and try to count it returns null.

 @if($product->check($product->id) == $product->id)
       <i class="far fa-heart icon" id="{{$product->id}}"></i>
@else
       <i class="fas fa-heart icon" id="{{$product->id}}"></i>
@endif

Table looks like this

id  user_id product_id  created_at  updated_at

What am i doing wrong?

12 Jul
1 week ago

FallOutBoi left a reply on Model Relationship Only One Column

@nakov Yeah thanks, its working fine

FallOutBoi left a reply on Model Relationship Only One Column

still the same thing unfortunately :(

FallOutBoi started a new conversation Model Relationship Only One Column

Hi, i am trying to display an image which is connected to the Product model, i wrote a few lines like this

Product.php; 

    public function productImages(){
      return $this->hasMany(ProductImage::class);
    }
    public function primary() {
    return $this->productImages()->select('image')->where('primary','=', 1)->get();
}

ProductImage.php

  public function product()
  {
      return $this->belongsTo(Product::class);
  }

I am trying to display only the image which has primary column set to true.Like this

<img class="card-img-top" src="/product_images/{{$product->primary()}}" alt="Card image cap">

But it returns this

/product_images/[{"image":"91N5ovoYjoL._SL1500__1562936575.jpg"}]

How can i select only the value which has the filename?

10 Jul
1 week ago

FallOutBoi started a new conversation Question About Dropzone Validation

Hi, im building a form with dropzone in it. I was wondering if i would not check images for validation can someone just change the maximum file size number in their browser and submit the form? The script is on the same page.

06 Jul
2 weeks ago

FallOutBoi left a reply on Method Differences?

Yeah, thanks

FallOutBoi started a new conversation Method Differences?

I am kinda new can someone explain me the difference between put/patch,delete and 'post', 'get'? Why these methods exist if i can just send using the standard POST and GET?

FallOutBoi left a reply on Show Form Sent Message After Redirect

Yeah i saw that i just wanted to for him to be clear that he can use it in whatever element he pleases.

05 Jul
2 weeks ago

FallOutBoi left a reply on Simulate A Mouse Clicks For An Alt

insert your script inside your page

FallOutBoi left a reply on Weird Function On Null Error

The problem is it should not enter the first if scope. Because the value of $request->input('subcategory') is null. But it does enter for whatever reason

FallOutBoi left a reply on Converting Laravel Form Collective To Normal HTML Form.

Should be

<form action="{{ route('categories.destroy', $category->id) }}" method="post" class="form-inline form-delete">
    @csrf
    @method('delete')

    <input type="hidden" name="id" value="{{ $category->id }}" />

    <button class="btn btn-xs btn-danger delete" name="delete_modal type="submit">
        @lang('categories.delete')
    </button>
</form>

FallOutBoi left a reply on Show Form Sent Message After Redirect

If you want to show it only on one form just move

@if(session()->has('message'))
    <div class="alert alert-success">
        {{ session()->get('message') }}
    </div>
@endif

To your specified form div

FallOutBoi started a new conversation Weird Function On Null Error

I am trying to insert inside a table when user has selected a subcategory but when its empty it says "Call to a member function first() on null" Even when i am checking if its null or not like so

  if($request->input('subcategory') !== null || !empty($request->input('subcategory')) || $request->input('subcategory') !== ""){
        $new = new SubCategory;
        $new->name_en = $request->input('us');
        $new->name_hy = $request->input('hy');
        $new->name_ru = $request->input('ru');
        $new->parent_id = $request->input('subcategory');
        $parent = Category::find($request->input('subcategory'))->first();
        $new->url_alias = $parent->url_alias . '/' .$request->input('url');
        $new->save();
        return redirect()->back()->with('message', trans('admin_categories.success'));
      }else{
        $new = new Category;
        $new->name_en = $request->input('us');
        $new->name_hy = $request->input('hy');
        $new->name_ru = $request->input('ru');
        $new->url_alias = $request->input('url');
        $new->save();
        return redirect()->back()->with('message', trans('admin_categories.success'));
      }
04 Jul
2 weeks ago

FallOutBoi started a new conversation Translation Using Database Table

Hi, i've made a table called categories where user can insert category name in three different languages and its url alias. It looks like this

id|name_us|name_hy|name_ru|url_alias|created_at|updated_at|

I want to use these translations in home page where categories will be shown, but i don't how to approach this more efficiently. I was thinking about checking language in controller but i don't know if it will be correct. I also have the lang files if needed. I was also wondering if i could just put these names in lang file.

02 Jul
2 weeks ago

FallOutBoi left a reply on Is It Okay To Use Data Objects Instead Of Array?

@SNAPEY - What about the performance? does it slow down anything?

FallOutBoi started a new conversation Is It Okay To Use Data Objects Instead Of Array?

I always displayed data on applications like so Controller :

$user = User::find($id)->firstOrFail();

View :

<span>$user->name</span>
<span>$user->lname</span>

I was just wondering, is this wrong or unpractical? To use an object instead of array or json or whatever.

FallOutBoi left a reply on Controller Won't Update Record

@RAS1212 - Nice answer but the input names are different compared to table column names, i changed to this and it worked

    public function update(Request $request, $id)
    {
        $data = User::where('id', $id)->first();
        if($data['id'] !== Auth::user()->id || $data === null) {
            return redirect('/')->withErrors(['Unauthorized access!']);
        }else{
            $validatedData = $request->validate(
                [
                'fname' => 'string|max:255',
                'lname' => 'string|max:255',
                'country' => 'string|max:45',
                'address' => 'string|max:100',
                'image' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
                ]
            );
            $fname = $request->input('fname');
            $lname = $request->input('lname');
            $country = $request->input('country');
            $address = $request->input('address');
            $image = $request->image;

                $data->first_name = $fname;
                $data->last_name = $lname;
                $data->country = $country;
                $data->address = $address;

            if($request->hasFile('image')) {
                $imageName = Auth::user()->unique_id.'.'.request()->image->getClientOriginalExtension();
                if($data['image'] !== 'default.png') {
                    Storage::delete('public/profile_images/'.$data['image']);
                }
                request()->image->move(public_path('storage/profile_images'), $imageName);
            }

            $data->save();
            return redirect()->back()->with('message', trans('profile.success'));
        }
    }

FallOutBoi left a reply on Controller Won't Update Record

@RAS1212 - Trying to check if the inputed fields are the same as in database, if so it should not change anything

FallOutBoi started a new conversation Controller Won't Update Record

Hi, i'm trying to build a simple profile update functionality, everything is set but for some reason it won't update the existing records. Here's some of my code

    public function update(Request $request, $id)
    {
        $data = User::find($id)->first();
        if($data['id'] !== Auth::user()->id || $data === null) {
            return redirect('/')->withErrors(['Unauthorized access!']);
        }else{
            $validatedData = $request->validate(
                [
                'fname' => 'string|max:255',
                'lname' => 'string|max:255',
                'country' => 'string|max:45',
                'address' => 'string|max:100',
                'image' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
                ]
            );
            $fname = $request->input('fname');
            $lname = $request->input('lname');
            $country = $request->input('country');
            $address = $request->input('address');
            $image = $request->image;

            if(!$fname === $data['first_name']) {
                $data->first_name = $fname;
            }

            if(!$lname === $data['last_name']) {
                $data->last_name = $lname;
            }

            if(!$country === $data['country']) {
                $data->country = $country;
            }

            if(!$address === $data['address']) {
                $data->address = $address;
            }

            if($request->hasFile('image')) {
                $imageName = Auth::user()->unique_id.'.'.request()->image->getClientOriginalExtension();
                if($data['image'] !== 'default.png'){
                  Storage::delete('public/profile_images/'.$data['image']);
                }
                request()->image->move(public_path('storage/profile_images'), $imageName);
            }
            
            $data->save();
            return redirect()->back()->with('message', trans('profile.success'));
        }
    }

It returns the success message but wont change anything else in the database. Here's the namespace part

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Auth;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Storage;
use Lang;

What am i doing wrong?

01 Jul
3 weeks ago

FallOutBoi started a new conversation How To Validate Country?

Hi, i am trying to build a simple registration form which includes a select with country list like this

    <select id="country" class="form-control" name="country" required>
                                            <option value="Afghanistan">Afghanistan</option>
                                            <option value="Albania">Albania</option>
                                            <option value="Algeria">Algeria</option>
                                            <option value="American Samoa">American Samoa</option>
                                            <option value="Andorra">Andorra</option>
                                            <option value="Angola">Angola</option>
                                            <option value="Anguilla">Anguilla</option>
                                            <option value="Antartica">Antarctica</option>
                                            <option value="Antigua and Barbuda">Antigua and Barbuda</option>
                                            <option value="Argentina">Argentina</option>
                                            <option value="Armenia">Armenia</option>
                                            <option value="Aruba">Aruba</option>
...

I can't find a way to validate this in User model, i tried to inject something else as country and it works.

here's my registration controller validation part

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'lname' => ['required', 'string', 'max:255'],
            'country' => ['required', 'string', 'max:45'],
            'address' => ['required', 'string', 'max:100'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

I was also thinking about putting all these countries inside one array and try to compare it to the data received in controller like so, but have no idea where to put it

$countries = ['us', 'am', 'ru' .... others] 
$country = $data['country'];
if(!in_array($country, $countries){
return false
}

FallOutBoi left a reply on Any Global Payment Systems Out There?

@MARTINBEAN - Yes but its not available in my country unfortunately

FallOutBoi started a new conversation Any Global Payment Systems Out There?

Hi, i am trying to build my own personal e-commerce website and i just want people from europe and asian territories to pay with their credit cards, but i can't find anything. I also want to receive the money on my own card account i am from Armenia. Is there a system that allows that?

30 Jun
3 weeks ago

FallOutBoi left a reply on Payment System?

@MARTINBEAN - Yeah, like any master card or visa from any country?

FallOutBoi started a new conversation Payment System?

Does laravel cashier supports master card, visa and other payments or i should find some other framework/library.

FallOutBoi started a new conversation Is This Unpractical?

Hello, i am building a simple e-commerce application with laravel and i have like 3 columns for each image location for products table. Is it unpractical to have seperate columns for image or is it best to have one column and fill it with information?