david19

david19

Member Since 8 Months Ago

Experience Points
2,720
Total
Experience

2,280 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
7
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.

Level 1
2,720 XP
Jan
10
1 week ago
Activity icon

Started a new Conversation Laravel Package Add Button

Hello Team. I would like add a button with my composer package, in the view. (View of App).... I can make new views, but not elements :( There are a little trick?

Jan
07
2 weeks ago
Activity icon

Replied to Difference Between Websocket And VUEX

Because here in germany, the courses are really bad. I watch only courses in english on laracasts, youtube or udemy. I love this method for learning, and i get better and better with laravel. I posted over 30 questions in this forum, and i get allways nice answers, which put me to the right way :)

You need a basic knowhow on vuex and websockets. After that, you can choose your next step.

Activity icon

Started a new Conversation Difference Between Websocket And VUEX

I saw many courses with laravel websockets or vuex. You can create realtime apps with this.

You can create a realtime chat with a websocket or with Vuex. Vuex storeing the data in a container.

What is the better approach? I dont know this, because i am new in Vuex, and i am new for websockets :)

Activity icon

Started a new Conversation Laravel Forge Websocket For All Clients

Hello Team, simple Question:

  1. I will buy a extra server on digital ocean via forge. On this server i will install only the laravel websocket (beyondco).

  2. I will buy a second server for my projects. Can i use this websocket for all projects which stands on other server?

If yes, how difficult is that? Because then, i will use only pusher.com. Its not free, but very easy. And i can use for all projects.

Activity icon

Started a new Conversation Laravel Backend API + Multiple Clients

Example: Maby we are a Developer. We create a Laravel Backend API with Passport.

It would be nice, only 1 Laravel Backend for all clients. The Problem is the databases. Every Client need a extra database. All clients use the api, but a extra database. For the developer its great, because he create only 1 Laravel Backend API.

There are a easy simple way for that? Many thanks :)

Jan
06
2 weeks ago
Activity icon

Started a new Conversation Fastest Technique For Loadspeed And User Smoothness

Its not easy, find good informations. Maby some members here find a answere.

1. Standart: Laravel + Blade + Cache + CDN  Backend: "Laravel" Frontend: "Laravel" little vue or react or angular
2.  Laravel + Vue + Vuex + Vrouter + Cache + CDN  Backend: "Laravel" Frontend: "Vue,Vuex,Vrouter"
3. Laravel + Nuxt.js + CDN Backend: "Laravel Api with Passport or JWT" Frontend: "Nuxt only"

What is the fastest technique for Loadspeed and User smoothness? I know, this question is not easy, but we can all put our experience here.

Dec
16
1 month ago
Activity icon

Replied to Why Laravel + Vue

Many thanks for answers :) Okay i understand now.

Activity icon

Started a new Conversation Why Laravel + Vue

Hello Team,

On Youtube and Udemy i watch many videos with Laravel backend + Vue Frontend. It is becoming popular. The Vue Frontend use the backend laravel Api for show posts or something.

My question is, why this combination is popular? Why not use Laravel for frontend,too.? Or Laravel with a little bit vue as combination.

In the videos i saw "routes" with the VUE Routing. Thats nice but why? And can google all read the js.code? (googlebot). Thanks for answers :)

Dec
12
1 month ago
Activity icon

Replied to Package (add Lines On Default)

Thanks for your answere. I try a little trick now, but it doesnt work :(

I created a package with only controllers. Example: mypackage/src/Http/Controllers/LoginController

This Controller should extend the Login Controller from the Auth Package and add this function:

<?php


namespace Extrem16\Auth\Http\Controllers;


use App\Http\Controllers\Auth\LoginController;



class AuthExtrem16Controller extends LoginController

{
  public function showLoginForm()
  {

      return 'my package work';

  }
}
Dec
11
1 month ago
Activity icon

Started a new Conversation Package (add Lines On Default)

Hello team,

i will create packages. I can make views, controllers,models,routes. This works. But how i can add functions in views, which are default?

Example Package: Add this function in /app/Http/Controllers/Auth/LoginController

public function showLoginForm()
    {

        return view('vendor.mytheme.auth.login');
        
    }

For this function i can not create a extra controller, because its the default laravel auth package.

Dec
03
1 month ago
Activity icon

Replied to (PHP) After Unzip Redirect

Yes!! Many thanks Sinnbeck :D

Activity icon

Replied to (PHP) After Unzip Redirect

Sorry its not work :( Yes i can access the url manually.

<?php
$file = 'my-dev.zip';
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
  $zip->extractTo($path);
  $zip->close();
  
header("Location: http://localhost/install.php");

} else {
  echo "Die Datei $file konnte nicht gefunden/ge&ouml;ffnet werden.";
}
exit;
?>

I dont understand :(

Activity icon

Replied to (PHP) After Unzip Redirect

Its not work :( After unzip all files, stands on the current site :( Maby its the .htaccess?

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/ [L]
Activity icon

Started a new Conversation (PHP) After Unzip Redirect

Hello Team. With this php, i will unzip my laravel folders. But after this, i will redirect to a other php file. The redirect doesnt work :(

<?php



$file = 'my-dev.zip'; //Dateiname entsprechend �ndern

$path = pathinfo(realpath($file), PATHINFO_DIRNAME);

$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
  $zip->extractTo($path);
  $zip->close();
  
header('/install.php');

} else {
  echo "Die Datei $file konnte nicht gefunden/ge&ouml;ffnet werden.";
}

exit;
?>
Dec
01
1 month ago
Activity icon

Replied to Git Init (not Found) On CMD Windows

Solved: I found gitbash :D

Activity icon

Started a new Conversation Git Init (not Found) On CMD Windows

Hello Team. I am a littlebit i'm confused :(

I will test laravel forge. All its fine. Setup the server and all works nice :) I made a fresh laravel app via composer on my windows10. Now i will put this new laravel app, to my git repository. If i type the first command:

git init

or

git status

My cmd on win10 doesnt found the commands. All tutorials which i see, its on mac or linux. My new Server on Forge works, but i can not push my laravel app to github :P

Nov
28
1 month ago
Activity icon

Started a new Conversation Chunk Collection With A @Include

Hello Team. I love the chunk method, for build a collection in the views. But now i have a @include, and i get error. I try use chunk in a card-deck.

<div class="card-deck">
@foreach ($product_categories as $product_category)
          <li>{{ $product_category->name }}</li>
          <ul>
          @foreach ($product_category->childrenCategories as $childCategory)
          @include('admin.shop.category.child_category', ['child_category' => $childCategory])
          @endforeach
          </ul>
          @endforeach
</div>

The problem is this @include file:

{{ $child_category->name }}
@if ($child_category->product_categories)
    <ul>
      @foreach ($child_category->product_categories as $childCategory)
          @include('admin.shop.category.child_category', ['child_category' => $childCategory])
      @endforeach
    </ul>
@endif
</div>
@foreach($product_categories->chunk(3) as $chunk)
@foreach ($chunk as $product_category)

Maby its not possible use chunk with @include :(

Activity icon

Replied to Dont Find The Right Query

@tisuchi Holy Shit, This works!!!!!!!!!!!!!!!!!!!!!

public function sub_categories($category_slug)
    {
$categories = Category::where('category_slug',$category_slug)->with('childrenCategories')->get();
return $categories;

    }
    
0   
id  20
created_at  "2019-11-28 05:32:53"
updated_at  "2019-11-28 05:32:53"
name    "Men"
parent_id   null
category_slug   "men"
description null
image   null
title   "Men"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null
children_categories 
0   
id  22
created_at  "2019-11-28 05:34:25"
updated_at  "2019-11-28 05:34:25"
name    "Jeans"
parent_id   20
category_slug   "jeans"
description null
image   null
title   "Jeans"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null
product_categories  
0   
id  24
created_at  "2019-11-28 05:37:31"
updated_at  "2019-11-28 05:37:31"
name    "Blue Jeans"
parent_id   22
category_slug   "blue-jeans"
description null
image   null
title   "Blue Jeans"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null

Soo many thanks :D

Activity icon

Started a new Conversation Dont Find The Right Query

Hello Team, sorry i need help again.

I have a categories table with unlimited subcategories.

ID##Name                ##Parent_ID          ##Category_slug
20##Men                 ##Null                     ##men
21##Women           ##Null                     ##women
22##Jeans               ##20                        ##jeans
23##Leggings        ##21                        ##jeans
24##Blue Jeans          ##22                        ##jeans
25##Red Leggings     ##23                        ##jeans

I made a route for the Shop View, which works fine :)

Route::get('/shop', 'Shop\Category\[email protected]_categories')
public function all_categories()
    {
      $categories = Category::whereNull('parent_id')->get();

      return $categories;
    }
0   
id  20
created_at  "2019-11-28 05:32:53"
updated_at  "2019-11-28 05:32:53"
name    "Men"
parent_id   null
category_slug   "men"
description null
image   null
title   "Men"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null
1   
id  21
created_at  "2019-11-28 05:33:03"
updated_at  "2019-11-28 05:33:03"
name    "Women"
parent_id   null
category_slug   "women"
description null
image   null
title   "Women"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null

Now i will try get only the subcategories.

Route::get('/shop/{category_slug}', 'Shop\Category\[email protected]_categories')
public function sub_categories(Category $category_slug)
    {

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

      return $categories;

    }
I visit localhost/shop/men (or women)

But i get all subcategories :(

0   
id  22
created_at  "2019-11-28 05:34:25"
updated_at  "2019-11-28 05:34:25"
name    "Jeans"
parent_id   20
category_slug   "jeans"
description null
image   null
title   "Jeans"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null
1   
id  23
created_at  "2019-11-28 05:34:54"
updated_at  "2019-11-28 05:34:54"
name    "Leggings"
parent_id   21
category_slug   "leggings"
description null
image   null
title   "Leggings"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null
2   
id  24
created_at  "2019-11-28 05:37:31"
updated_at  "2019-11-28 05:37:31"
name    "Blue Jeans"
parent_id   22
category_slug   "blue-jeans"
description null
image   null
title   "Blue Jeans"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null
3   
id  25
created_at  "2019-11-28 05:37:45"
updated_at  "2019-11-28 05:37:45"
name    "Red Leggings"
parent_id   23
category_slug   "red-leggings"
description null
image   null
title   "Red Leggings"
alt_img null
canonical_org   null
canonical_new   null
robots  1
meta_description    null

The View if "men" should only show "Jeans". Sorry for the long text :(

Nov
27
1 month ago
Activity icon

Started a new Conversation Why @foreach Override My Textarea

Hello Team. I dont understand why PHP do that. Because i am a beginner. I have a Edit View with 2 Formgroups:

<div class="form-group">
          <div class="card bg-darkblue text-white border border-white">
          <div class="card-header bg-darkblue text-white">
          CHANGE PARENTCATEGORY?
          </div>
          <div class="card-body bg-darkblue text-white">
          <label for="exampleFormControlSelect1"></label>
          <select  name="parent_id" class="form-control bg-darkblue text-white" id="exampleFormControlSelect1">
          <option value="0">No</option>
          @foreach($product_categories as $product_category)
          <option value="{{$product_category->id}}">{{$product_category->name}}</option>

          @endforeach
          </select>
          </div>
          <div class="card-footer bg-darkblue text-white">
          </div>
          </div>
          </div>
<div class="form-group">
          <div class="card bg-darkblue text-white border border-white mt-5">
          <div class="card-header bg-darkblue text-white">
          CATEGORY DESCRIPTION
          </div>
          <div class="card-body bg-darkblue text-white">
          <textarea class="form-control" id="summernote" rows="3" name="description" value="{{$product_category->description}}">{{$product_category->description}}</textarea>
          <script>
          $('#summernote').summernote({
          placeholder: '',
          tabsize: 2,
          height: 100
          });
          </script>
          </div>
          <div class="card-footer bg-darkblue text-white">
          </div>
          </div>
          </div>

Why this foreach loop override my Textvalue in the Textarea? I closed the loop before, i dont understand. If i change the loop name:

@foreach($product_categories as $product_cat)
          <option value="{{$product_category->id}}">{{$product_cat->name}}</option>

          @endforeach

it will works, but then it will not save the parent category.

Nov
25
1 month ago
Activity icon

Replied to DoesntHave Query

@tisuchi Many thanks :D

Activity icon

Started a new Conversation DoesntHave Query

Hello Team.

I have a categorie Table with unlimted Subcategories

Id### Name###Parentid
1 ### Car ### Null
2 ###Bmw### 1
3 ###Ford###  1

When i go to my "EDIT" Page, i can choose my parent category. But the problem is, when i go to the "Ford" Edit Page, i can set "Ford" as Parent. But this is not correct. Ford can not a parent of Ford. Now i try to fix this, but i can not fix this. I need all categories which as not the "ID", which i edit. This is what i try now:

$category = category::find($id);
$categories = category::doesntHave('????')->get();
Nov
24
1 month ago
Activity icon

Started a new Conversation Laravel NodeJs After DEV

Hello Team, I have a question.

For compile styles i need npm. Example: I will add a bootstrap Root:Class Color. After that i compile this with NPM. All its good.

Now i will put my laravel on the live server. Should i unistall all NPM Files via composer? Or its that not necessary?

Activity icon

Started a new Conversation Very Much @include Performance?

Hello Team,

How much reduce includes the performance in blade files? I like this example here, because its much more readable and very clean. I mean put all cards via includes :)

@extends('layouts.app')
@section('inline-css')
<style></style>
@endsection
@section('main-css')
<link href="{{ asset('assets/css/bootstrap.min.css') }}" rel="stylesheet">
@endsection
@section('content')
<div class="container bg-light rounded text-white">
<div class="row">
@include('admin.layouts.sidebar')
<div class="col-xs-12 col-sm-12 col-md-10 col-lg-10 col-xl-10">
@include('card.1')
@include('card.2')
@include('card.3')
@include('card.4')
@include('card.5')
@include('card.6')
@include('card.7')
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="{{ asset('assets/js/jquery-3.4.1.min.js') }}"></script>
<script src="{{ asset('assets/js/bootstrap.min.js') }}"></script>
@endsection
Nov
23
1 month ago
Activity icon

Replied to Radio Button Uncheck (best Way?)

@tray2 Yes, the checkbox are better, but checkbox allows multiple selects. Can you show me a example with <18 or >18 please?

Activity icon

Replied to Radio Button Uncheck (best Way?)

I found a very go way for me. I think its the best. Put this over the @foreach in the radio form:

<input type="radio" class="radio" name="parent_id" value="0" checked> No Parent Category

In the controller:

if($request->parent_id == 0)
      {
        $category->parent_id = NULL;
      }

Thats it! :D

Activity icon

Started a new Conversation Radio Button Uncheck (best Way?)

Hello Team, I use Laravel 6 with Bootstrap: I saw a new problem. I have Categories with Parent Categories. If i check a radio button, then i can not uncheck in my form.

Yes, i can make a standart category_base, and make a if statement and set parent_id to "NULL". But the problem is, in the future i loaded allways this category_base in my "foreach" blade files. I think that is not the best solution.

How you deal with this? Do you make this with javascript, all what is the best way? Many thanks.

Nov
21
2 months ago
Activity icon

Started a new Conversation Laravel Tutorial (Create A Installer)

There are any tutorial for create a installer for a laravel application? You know the installers of wordpress or october cms. Maby laracasts?? But i dont find a tutorial. There are a package on github, but this is only for the migrations.

Activity icon

Replied to Category_Slug For Subviews

I think this works:

 $categories = category::where('category_slug',$category_slug)->with('categories')->get();
Activity icon

Replied to Category_Slug For Subviews

Thanks Nakov, i know. But now i get only "cars" without Subcategories.

localhost/shop/cars
0   
id  1
name    "Cars"
parent_id   null
category_slug   "cars"
created_at  "2019-11-21 00:00:00"
updated_at  "2019-11-21 00:00:00"

But i need all subcategories in cars.

0   
id  2
name    "BMW"
parent_id   1
category_slug   "bmw"
created_at  "2019-11-21 00:00:00"
updated_at  "2019-11-21 00:00:00"
1   
id  3
name    "Ford"
parent_id   1
category_slug   "ford"
created_at  "2019-11-21 00:00:00"
updated_at  "2019-11-21 00:00:00"

That is the problem if i use RouteKeyName :(

Activity icon

Started a new Conversation Category_Slug For Subviews

Hello Team, sorry for the question again, but i tryed many hours before :)

ID 1: Cars = parent_id = NULL
ID 2: BMW = parent_id = 1
ID 3: Ford = parent_id =  1
ID 4: Bikes = parent_id = NULL
ID 5: Cross-Bike = parent_id = 4

With this Line i get all subcategories with the id.

public function subcategories($id)
    {
      $categories = category::where('parent_id',$id)->get();
      return $categories;

    }
localhost/shop/1
0   
id  2
name    "BMW"
parent_id   1
category_slug   "bmw"
created_at  "2019-11-21 00:00:00"
updated_at  "2019-11-21 00:00:00"
1   
id  3
name    "Ford"
parent_id   1
category_slug   "ford"
created_at  "2019-11-21 00:00:00"
updated_at  "2019-11-21 00:00:00"

Instead of ID, i like the category_slug "cars".

localhost/shop/cars
Route::get('/shop/{category_slug}', 'Shop\Product\[email protected]')
public function subcategories($category_slug)
    {
      $categories = category::where('parent_id',$category_slug)->get();
      return $categories;

    }

I get nothing :(

Activity icon

Replied to Query Show Sub-category

Yes that works. Many thanks! But when i go to localhost/shop/bikes, i get BMW and Ford, because i use parent_id = 1. I use RouteKeyName

Yes, i can make a new line for the Bikes, but it is possible in automatic? I can not make a new line for all Subviews :)

Activity icon

Started a new Conversation Query Show Sub-category

Hello Team,

ID 1: Cars = parent_id = NULL
ID 2: BMW = parent_id = 1
ID 3: Ford = parent_id =  1
ID 4: Bikes = parent_id = NULL
ID 5: Cross-Bike = parent_id = 4

I would like a view with only BMW and Ford. But i get allways with the Cross Bike :( Relationship Category Model

return $this->hasMany('App\Category', 'parent_id');
public function subcategories()
    {
      $categories = Category::where('parent_id')->???->get();
    }

Nov
19
2 months ago
Activity icon

Replied to URL With RouteKeyName And Eloquent

Ohh sorry Sinnbeck. Now it works!! I tryed before this:

Public function product( Category $category, Product $product, $id )

But the ID must stay on first place.

public function product($id, Category $category, Product $product)

Sinnbeck you are my men! Many thanks :D

Activity icon

Replied to URL With RouteKeyName And Eloquent

Yes, exactly! If i use this, i get the url witout view, because i need a Eloquent.

Activity icon

Started a new Conversation URL With RouteKeyName And Eloquent

Hello Team, My url for the single view works fine with RouteKey. This works for me:

Route::get('/shop/{category}/{product}', 'Shop\Product\[email protected]')->name('guest.shop.product.product');
public function product(Category $category, Product $product)
{

    return view('guest.shop.product.product',compact('product','category'));

}

I can see my view here: This works! http://localhost/shop/water/smoke-intro

But now i will put my id before. This:

Route::get('/shop/{id}/{category}/{product}

How i can use Eloquent with my setup? I tryed many thinks, but it doesnt work. Many thanks for help.

Nov
18
2 months ago
Activity icon

Replied to Form Checked @if

This found my mistake. Many thanks Nakov. I made a mistake in my table column. It wars "Category_id" and not "category_id".

Activity icon

Started a new Conversation Form Checked @if

My forms works great. But for my edit view, the checked mark doesnt work.

I have a relationship Product with Categories.

If the Category_id ( Table:Products) , same as ID (Table:Categories), it should be checked! This not work..

@foreach ($categories as $category)
<label>
<input type="radio" name="category_id" id="optionsRadios1" value="{{$category->id}}" @if ($product->category_id == $category->id) checked @endif>
</label>
{{ $category->name }}
<br>
@endforeach
Activity icon

Replied to Laravel Core Files And Public Files Different IP Possible?

Ahh Okay many thanks.

The problem is, the user must upload all the files and migrate his database. Sure, you can use a laravel installer, for easy steps. But he can not update the core, if i make changes. I think the simple way is, same wordpress. You get a message, "Update now". And the application update your core.

Activity icon

Replied to Laravel Core Files And Public Files Different IP Possible?

I mean only the public folder. But i dont know. I think the PHP Code,too. Because the application can create posts etc....

Activity icon

Started a new Conversation Laravel Core Files And Public Files Different IP Possible?

Hello Team, i have a question again.

Example: I upload my laravel App to my ftp server.

Its possible upload the public files on my friend ftp and connect to my laravel core files?

Laravel Core Files stands on my IP adress, and the Public Files stands on different IP.

If the answere "Yes", how reduce the performance?

Activity icon

Replied to Rename Database Column

Many thanks guys! Change the format works! Many thanks!

public function categories()
    {
        return $this->hasMany('App\Category', 'parent_id');
    }

    public function childrenCategories()
{
    return $this->hasMany('App\Category','parent_id')->with('categories');
}
Activity icon

Replied to Rename Database Column

The Traceback show me this:

C:\xampp\htdocs\developer\extrem16-base-1.0\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
     * @throws \Illuminate\Database\QueryException

     */

    protected function runQueryCallback($query, $bindings, Closure $callback)

    {

        // To execute the statement, we'll simply call the callback, which will actually

        // run the SQL against the PDO connection. Then we can calculate the time it

        // took to execute and log the query SQL, bindings and time in our memory.

        try {

            $result = $callback($query, $bindings);

        }

 

        // If an exception occurs when attempting to run a query, we'll format the error

        // message to include the bindings with SQL, which will make this exception a

        // lot more helpful to the developer instead of just the database's errors.

        catch (Exception $e) {

            throw new QueryException(

                $query, $this->prepareBindings($bindings), $e

            );

        }

 

        return $result;

    }

 

    /**

     * Log a query in the connection's query log.

     *

     * @param  string  $query

     * @param  array   $bindings

     * @param  float|null  $time

     * @return void

     */
Activity icon

Started a new Conversation Rename Database Column

Hello Team. I have a relation table "categories" with a column ForeignKey"category_id". It works all fine. But now i will change the name. "category_id" --> "parent_id". I deleted the table, and i made a new migration. Now the database is correct and shows "parent_id". I changed all my files and replace "category_id" with "parent_id". All is clean now. But laravel give me a error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categories.category_id' in 'where clause' (SQL: select * from `categories` where `categories`.`category_id` in (1)) 

Laravel search for the category_id column, but i changed all files to parent_id. How i can fix this? Should i delete the model, and remake them??

Nov
17
2 months ago
Activity icon

Replied to Allways DELETE Last Record

OHHHH, now it works!!!!!!! Thank you soo much sir :)

Activity icon

Replied to Allways DELETE Last Record

This wars the edit view, for my categories. I build a category tree. This foreach come from the controller:

public function edit($id)
    {
        $category = Category::find($id);
        $categories = Category::paginate(5);
        return view('admin.shop.category.edit',compact('category','categories'));
    }

The foreach loop is closed, but dont know where is the mistake. Should i move the Delete form in a other view?

Activity icon

Replied to Allways DELETE Last Record

@extends('layouts.app')
@section('inline-css')
<style></style>
@endsection
@section('main-css')
<link href="{{ asset('assets/css/bootstrap.min.css') }}" rel="stylesheet">
@endsection
@section('content')
<!--container   -->
<div class="container">
<!--main row   -->
<div class="row">
<!--main col-12 -->
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="card">
<div class="card-header bg-dark text-white">
<h2>Create a Category</h2>
</div>
<div class="card-body text-center">
<!--1. row -->
<div class="row">
<!--1. col-12 -->
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="card">
<div class="card-header bg-dark text-white">
Create a Category
</div>
<div class="card-body">

  <form method="POST" action="{{route('admin.shop.category.update',$category->id)}}">
  @method('PUT')
  @csrf

  <div class="form-group">
    <label for="name">Name</label>
  <input type="text" class="form-control" placeholder="" name="name" value="{{$category->name}}">
  </div>

  <div class="form-group">
    <div class="radio">
  @foreach ($categories as $category)
  <label>
  <input type="radio" name="category_id" id="optionsRadios1" value="{{$category->id}}">
  <div class="card">
  {{$category->name}}
  </label>
  </div>
  <br>
  @endforeach
  </div>
  </div>
{{ $categories->links() }}
</div>
<div class="card-footer">
  <input type="submit" class="btn btn-primary" value="Submit">
</form>

<form method="POST" action="{{ route('admin.shop.category.destroy',$category->id )}}">
  @method('DELETE')
  @csrf
<input type="submit" class="btn btn-danger float-right" value="Delete">
</form>


</div>
</div>
<!--end 1. col-6 -->
</div>

<!--end 1. row -->
</div>
</div>
</div>
<div class="card-footer bg-dark text-white">
<a class="btn btn-warning" href="{{route('admin.shop.category.index')}}" role="button">Back</a>
</div>


<!--end main col-12 -->
</div>
<!--end main row   -->
</div>
<!--end container   -->
</div>
@endsection
@section('scripts')
<script src="{{ asset('assets/js/jquery-3.4.1.min.js') }}"></script>
<script src="{{ asset('assets/js/bootstrap.min.js') }}"></script>
@endsection
Activity icon

Replied to Allways DELETE Last Record

Yes here is the mistake. I get allways the last input, when i click delete. The correct ID is "88" not "110".

array:5 [▼
  "id" => 110
  "created_at" => "2019-11-17 05:35:32"
  "updated_at" => "2019-11-17 05:35:32"
  "name" => "Kleidung"
  "category_id" => null
]
Activity icon

Replied to Allways DELETE Last Record

Its the same result. I dont know, what is this :D Maby its a loop problem?