Lestah

Lestah

Member Since 1 Year Ago

Experience Points 4,010
Experience Level 1

990 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 20
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

21 Feb
1 day ago

Lestah left a reply on How Did It End As An Array?

@CRONIX - I'ma use it always now since its your recommendation... 2000 id yeah i think i wouldn't get a product that much

Lestah left a reply on How Did It End As An Array?

@CRONIX - hey guys @cronix @snapey thanks for ur help I just solved it what i did is just this on my products controller i query this


$productDetails = Product::with('attributes')->where('id', $id)->first();
and do test like what you advc


and then on my view page i did this like what @cronix suggested


@foreach($productDetails->attributes as $attribute)


and it now displays i just need a couple hours of sleep to figure that one out haha thanks a lot

20 Feb
2 days ago

Lestah left a reply on How Did It End As An Array?

@CRONIX - i got a product_view.blade.php which have a datatable of product ID, category ID, Category Name and so on.. the table contains add edit delete view on the add button i got


<a href="{{ url('/admin/add-attributes/'.$product->id) }}" class="btn btn-success btn-mini">Add</a>


that's why i have a route on my web.php


Route::match(['get', 'post'], '/admin/add-attributes/{id}','[email protected]');


so it will go to my controller addAttributes

when i dd($id); it gives me the product_id that i click on the table which is correct thats what i expect

i tried this removed the relationship


$productDetails = Product::where(['id' => $id])->first();
dd($productDetails);

it gives me this

Product {#241 ▼
  #connection: "mysql"
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:10 [▶]
  #original: array:10 [▶]
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #events: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #fillable: []
  #guarded: array:1 [▶]
}


i trink I have to troubleshoot more

Lestah left a reply on How Did It End As An Array?

@CRONIX - (1/1) ErrorException Argument 1 passed to Illuminate\Database\Grammar::columnize() must be of the type array, string given, called in C:\xampp\htdocs\online-shop\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 131 and defined

this the error i came up.. I'm still trying to search on laravel documentation

Lestah left a reply on How Did It End As An Array?


return view('admin.products.add_attributes', compact('productDetails'));

tried this one does not work :C

Lestah left a reply on How Did It End As An Array?

@JLRDW - i see but i cant get the data to my view page

Lestah started a new conversation How Did It End As An Array?

here's my controller


public function addAttributes(Request $request, $id=null)
    {
        $productDetails = Product::with('attributes')->where(['id' => $id])->first();
        $productDetails = json_decode(json_encode($productDetails));
        echo "<pre>"; print_r($productDetails); die;
    }

it gives me this


stdClass Object
(
    [id] => 3
    [category_id] => 2
    [product_name] => valenciaga
    [product_code] => 4
    [product_color] => black
    [description] => quality shoes running shoes
    [price] => 200
    [image] => 87910.jpeg
    [created_at] => 2019-02-20 11:51:18
    [updated_at] => 2019-02-20 11:52:28
    [attributes] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 1
                    [product_id] => 3
                    [sku] => rt-1
                    [size] => small
                    [price] => 200
                    [stock] => 5
                    [created_at] => 2019-02-20 16:16:51
                    [updated_at] => 2019-02-20 16:16:51
                )

            [1] => stdClass Object
                (
                    [id] => 2
                    [product_id] => 3
                    [sku] => rt-2
                    [size] => medium
                    [price] => 300
                    [stock] => 10
                    [created_at] => 2019-02-20 16:16:51
                    [updated_at] => 2019-02-20 16:16:51
                )

now here my view page


@foreach($productDetails['attributes'] as $attribute)
                <tr class="gradeX">
                  <td>{{ $attribute->id }}</td>
                  <td>{{ $attribute->sku }}</td>
                  <td>{{ $attribute->size }}</td>
                  <td>{{ $attribute->price }}</td>
                  <td>{{ $attribute->stock }}</td>
                  <a rel="{{ $attribute->id }}" rel1="delete-product" href="javascript:"  class="btn btn-danger btn-mini deleteRecord">Delete</a>
                </tr>
                @endforeach


now i got an error like this

2/2) ErrorException Trying to get property of non-object

should i use


<td>{{ $attribute['id'] }}</td>


to view my data?

Lestah left a reply on Class 'App\ProductsAttributes' What Does It Mean?

@CRONIX - yeah i know that convention i just dont know why have hand slip an s on my model haha well any thanks a lot helping me

Lestah left a reply on Class 'App\ProductsAttributes' What Does It Mean?

@CRONIX - its ProductsAttributes with s

Lestah left a reply on Class 'App\ProductsAttributes' What Does It Mean?

@CRONIX - Hi Cronix :D

this is my model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;


class Product extends Model
{
    public function attributes()
    {
        return $this->hasMany('App\ProductsAttributes','product_id');
    }
}

this my controller


public function addAttributes(Request $request, $id=null)
    {
        $productDetails = Product::with('attributes')->where(['id' => $id])->first();
        $productDetails = json_decode(json_encode($productDetails));
        echo "<pre>"; print_r($productDetails); die;

    }

I'm trying to get all the attributes of a product like size color price so on my model i have the 1 to many relation

no idea why it's giving me errors

Lestah started a new conversation Class 'App\ProductsAttributes' What Does It Mean?

On my controller i added


use App\ProductsAttribute;


ProductsAttribute is my model why em i getting this kind of error?

Lestah left a reply on Why I'm Getting This NotFoundHttpException

nah dont worry i got forgot the slash on my view page how to delete this question?

Lestah started a new conversation Why I'm Getting This NotFoundHttpException

here's my route

Route::match(['get', 'post'], '/admin/add-attributes/{id}', '[email protected]');

here's my controller


public function addAttributes(Request $request, $id=null)
    {
        $productDetails = Product::where(['id'=>$id])->first();

        if($request->isMethod('post')) {
            $data = $request->all();
            echo "<pre>"; print_r($data); die;
        }
        return view('admin.products.add_attributes')->with(compact('productDetails'));

    }


here's my view


action="{{ url('/admin/add-attributes'.$productDetails->id) }}"

do i need to clear route cache? how to do that?

Lestah left a reply on Could Not Open Input File: Artisans

@MANELGAVALDA - the original project is on my htdocs folder and the backup i created as well

Lestah started a new conversation Could Not Open Input File: Artisans

I duplicate a copy of my project to serve as back-up but when i try to run it with php artisan serve on cmd it says could not open input files

19 Feb
3 days ago

Lestah left a reply on How To Get All The Data From My Database

@RONB1985 - thanks for all your help guys its now working i just did what @ronb1985 sed i just want to get all the categories which have an id so basically 0 is included

i use this like what @ronb1985 suggested

$levels = Category::whereNotNull('parent_id')->get();

Lestah left a reply on How To Get All The Data From My Database

@RONB1985 - i want to include all numbers including zero

Lestah left a reply on How To Get All The Data From My Database

i can't get any data on this syntax but im using it on my edit update delete its working but on my addCategory Controller its not giving me hte list


$levels = Category::where(['parent_id'=>0])->get();

Lestah left a reply on How To Get All The Data From My Database

@TOMOPONGRAC - there's none when i tried dd il double check my query thanks @t

Lestah started a new conversation How To Get All The Data From My Database

here's my view add_category.blade.php i just want to get all the category from my categories table and list it on my dropdown list so when the page displays i can select from the drowdown list and add whatever i choose from the list coming from my database table categories


<div class="control-group">
                <label class="control-label">Category Level</label>
                <div class="controls">
                  <select name="parent_id" style="width: 220px;">
                    <option value="0">Main Category</option>
                    @foreach($levels as $val)
                      <option value="{{ $val->id }}">{{ $val->name }}</option>
                    @endforeach
                  </select>
                </div>
 </div>

here's my controller CategoryController

public function addCategory(Request $request)
    {
        if($request->isMethod('post')){
            $data = $request->all();
            //echo "<pre>"; print_r($data); die;
            $category = new Category;
            $category->name = $data['category_name'];
            $category->parent_id = $data['parent_id'];
            $category->description = $data['description'];
            $category->url = $data['url'];
            $category->save();
            return redirect('/admin/view-categories')->with('flash_message_success','Category added Successfully!');
        }

        $levels = Category::where(['parent_id'=>0])->get();

        return view('admin.categories.add_category')->with(compact('levels'));
    }

here's my route


Route::match(['get','post'],'/admin/add-category','[email protected]');


Laravel is not giving me any errors

17 Feb
5 days ago

Lestah left a reply on I Got An Error When Upgrading My Laravel 5.4 To 5.6

@ARTHVRIAN - will that work have you tried it?

16 Feb
6 days ago

Lestah left a reply on I Got An Error When Upgrading My Laravel 5.4 To 5.6

@JLRDW - what do i need to do i don't want to uninstall my current xampp i have alot of database stored in there

Lestah started a new conversation I Got An Error When Upgrading My Laravel 5.4 To 5.6

Problem 1 - This package requires php ^7.1.3 but your PHP version (5.6.30) does not satisfy that requirement. Problem 2 - laravel/framework v5.7.9 requires php ^7.1.3 -> your PHP version (5.6.30) does not satisfy that requirement.

this what my command line says

i dont know how to upgrade my php on laravel

Lestah left a reply on I'm Using A Laravel Version 5.4 How Can I Upgrade It To 5.6?

@TYKUS - thanks for making it clear tykus :D

Lestah left a reply on I'm Using A Laravel Version 5.4 How Can I Upgrade It To 5.6?

@TYKUS - i see so they will stay the same as long as i dont make changes on those directories that they have...

i just want know after i upgraded my laravel to 5.6 so lets say I'm going to create a new project again

if i type composer create-project laravel/laravel project_name to command promp to create a new project

are they going to be on laravel 5.6 automatically

Lestah left a reply on I'm Using A Laravel Version 5.4 How Can I Upgrade It To 5.6?

@TYKUS - ah so u mean to say that those projects that i did on laravel 5.4 will not be affected? but the future projects that i will create will be on laravel 5.6 automatically

Because I'm so worried that i may break those old projects that i did on laravel version 5.4

Lestah started a new conversation I'm Using A Laravel Version 5.4 How Can I Upgrade It To 5.7?

i have some laravel projects on my xampp htdocs folder as well are they going to be affected?

14 Feb
1 week ago

Lestah started a new conversation Request Whats This For?

in controller for sample


public function store()
{
    return request('description');
}

Lestah left a reply on Is This The Right Way Of Editing A Form?

@VILFAGO - really could you tell me how?

Lestah left a reply on Is This The Right Way Of Editing A Form?

thanks bro would it matter I'm using Laravel version is 5.4 and these tutorial is 5.7 well anyway since its your recommendation i'l do it haha thanks a lot @ for the advice

13 Feb
1 week ago

Lestah left a reply on Is This The Right Way Of Editing A Form?

@CRONIX - i see so for now i'll stick to the basics of laravel... by the way I now know how crud works on this framework... cud you give me some tips on what to focus on next like what the important part of the framework that I should focus on cause i plan to build an Ecommerce site

Lestah left a reply on What Is The Best Js Framework To Use With Laravel

@ARTCORE - some of friends feel the same way too. but i don know guess i haven't tried it...

Lestah left a reply on Is This The Right Way Of Editing A Form?

@CRONIX - is it going to be much complicated or a lot harder if i decided not to use any js.framework like react or vue? or it is really a necessary thing to know

Lestah started a new conversation What Is The Best Js Framework To Use With Laravel

is it really worth to try it than pure jquery ajax coding?

Lestah left a reply on Is This The Right Way Of Editing A Form?

@CRONIX - i did the update with no errors haha i just need some advc before i always doing my crud on native php with jquery ajax so its kind of faster is it ok if i did that on laravel framework?

Lestah left a reply on Is This The Right Way Of Editing A Form?

@CRONIX - yup thanks @cronix i can now see the data on my edit page i'l try to update it hoping i would not encounter any error this time

Lestah left a reply on Is This The Right Way Of Editing A Form?

@CRONIX - but on my edit.blade.php there will be a button that will update the form

<form action="{{ route('posts.update', $posts->id) }}" method="POST">

instead of this


<form action="{{ route('post.edit', $posts->id) }}" method="POST">

sorry I'm used to native php

Lestah left a reply on Is This The Right Way Of Editing A Form?


+-------------------+---------------+---------------------------------------------+--------------+
| Domain | Method    | URI               | Name          | Action                                      | Middleware   |
+--------+-----------+-------------------+---------------+---------------------------------------------+--------------+
|        | GET|HEAD  | about             |               | App\Http\Controllers\[email protected]   | web          |
|        | GET|HEAD  | api/user          |               | Closure                                     | api,auth:api |
|        | GET|HEAD  | contact           |               | App\Http\Controllers\[email protected] | web          |
|        | GET|HEAD  | home              |               | App\Http\Controllers\[email protected]    | web          |
|        | POST      | posts             | posts.store   | App\Http\Controllers\[email protected]   | web          |
|        | GET|HEAD  | posts             | posts.index   | App\Http\Controllers\[email protected]   | web          |
|        | GET|HEAD  | posts/create      | posts.create  | App\Http\Controllers\[email protected]  | web          |
|        | GET|HEAD  | posts/{post}      | posts.show    | App\Http\Controllers\[email protected]    | web          |
|        | PUT|PATCH | posts/{post}      | posts.update  | App\Http\Controllers\[email protected]  | web          |
|        | DELETE    | posts/{post}      | posts.destroy | App\Http\Controllers\[email protected] | web          |
|        | GET|HEAD  | posts/{post}/edit | posts.edit    |

Lestah left a reply on Is This The Right Way Of Editing A Form?

@CRONIX - yup i know I'm just resource will automatically do the crud routes :D

Lestah left a reply on Is This The Right Way Of Editing A Form?

@DRLDEJACTO - it is from the cmd how can get it to paste here ctrl-c but when i paste it here its messed up

Lestah left a reply on Is This The Right Way Of Editing A Form?

@DRLDEJACTO - --------+-----------+-------------------+---------------+---------------------------------------------+--------------+ | Domain | Method | URI | Name | Action | Middleware | +--------+-----------+-------------------+---------------+---------------------------------------------+--------------+ | | GET|HEAD | about | | App\Http\Controllers\[email protected] | web | | | GET|HEAD | api/user | | Closure | api,auth:api | | | GET|HEAD | contact | | App\Http\Controllers\[email protected] | web | | | POST | posts | posts.store | App\Http\Controllers\[email protected] | web | | | GET|HEAD | posts | posts.index | App\Http\Controllers\[email protected] | web | | | GET|HEAD | posts/create | posts.create | App\Http\Controllers\[email protected] | web | | | DELETE | posts/{post} | posts.destroy | App\Http\Controllers\[email protected] | web | | | GET|HEAD | posts/{post} | posts.show | App\Http\Controllers\[email protected] | web | | | PUT|PATCH | posts/{post} | posts.update | App\Http\Controllers\[email protected] | web | | | GET|HEAD | posts/{post}/edit | posts.edit | App\Http\Controllers\[email protected] | web | +--------+-----------+-------------------+---------------+---------------------------------------------+--------------+

Lestah started a new conversation Is This The Right Way Of Editing A Form?

Route::get('posts/{id}/edit', '[email protected]'); 

i added this one on my web.php even-though i have Route:resource

so when i type localhost8000/posts/1/edit

it should give me the edit page with the form with value

here's my controller


public function edit($id)
    {
     
        $posts = Post::find($id);
        
        return view('posts.edit')->withPosts($posts);
    }

here's my view page edit.blade.php


<form action="{{ route('posts/'.$posts->id) }}" method="POST">
        {{ csrf_field() }}
    
      <div class="form-group">
          <label for="exampleInputEmail1">Title</label>
          <input type="hidden" name="_method" value="PUT">
          <input type="hidden" name="_token" value="{{ csrf_token() }}">
          <input type="text" class="form-control" name="title" placeholder="Enter title" value="{{ $posts->title }}">
      </div>
      <div class="form-group">
          <label for="exampleTextarea">Body</label>
          <textarea class="form-control" name="body" rows="3">{{ $posts->body }}</textarea>
        </div>
        <div class="form-group">
          
          <input type="submit" class="btn btn-success btn pull-right" value="update">
        </div>

      </form>

but it give me error when i try to view the edit page localhost/8000/posts/1/edit it says Route [posts/1] not defined.

Lestah left a reply on How Can I Display All The Data On My Database Table To My View

@CRONIX - it works thanks a lot @cronix now i can move on

Lestah left a reply on How Can I Display All The Data On My Database Table To My View

@CRONIX - i see so the show method is just for one data and index is if you want all data. cause what I'm trying to do is appending an id as well on the index method haha but now i know il try again

12 Feb
1 week ago

Lestah left a reply on How Can I Display All The Data On My Database Table To My View

@SNAPEY - here my PostController


public function store(Request $request)
    {
        //

        $posts = new Post();

        $posts->title = request('title');
        $posts->body = request('body');
        //$posts->title = $request->title;
        //$posts->body = $request->body;

        $posts->save();

        //return redirect('posts');
        return redirect()->route('posts.show', $posts->id);


    }

public function show($id)
    {
        //
        $posts = Post::find($id);
        //return view('posts.show')->withPost($post); shortcut
        return view('posts.home')->with('posts', $posts);
    }

the variable that i passed is posts so i what did is access it on the foreach

Lestah started a new conversation How Can I Display All The Data On My Database Table To My View

on my home.blade.php heres what i have


<div class="row">
      <div class="col-lg-8 col-md-10 mx-auto">
      @foreach( $posts as $post )
        <div class="post-preview">
          <a href="post.html">
            <h2 class="post-title">
              {{ $post->title }}
            </h2>
            <h3 class="post-subtitle">
              {{ $post->title }}  
              
            </h3>
          </a>
          <p class="post-meta">Posted by
            <a href="#">Start Bootstrap</a>
            on September 24, 2019</p>
        </div>
        <hr>
      @endforeach

it gives an error undefined variable posts

Lestah left a reply on A Simple Question About Posting A Form

@RONB1985 - i found out what the problem is i was just a typo thanks anyway :D