wuschelino22

wuschelino22

Member Since 1 Month Ago

Experience Points 690
Experience Level 1

4,310 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 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.

29 May
3 weeks ago

wuschelino22 left a reply on Update With CRUD

i understand it a little bit. but when i do the changes an i want to edit a database entry in the browser headpanel they go tho the following adress.

http://localhost/shares/24?_method=PATCH&_token=HwM2YJhPyqWmPfpFHTjNtT3TpfJg0YISMMWXpKQi&name=Testttt&urls=Test

But it do not any changes in my database :-(

wuschelino22 left a reply on Update With CRUD

+--------+-----------+----------------------+----------------+------------------ -----------------------------------+--------------+ | Domain | Method | URI | Name | Action | Middleware | +--------+-----------+----------------------+----------------+------------------ -----------------------------------+--------------+ | | GET|HEAD | / | | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | api/user | | Closure | api,auth:api | | | GET|HEAD | create | | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | edit/{id} | | App\Http\Controll ers\[email protected] | web | | | POST | search | | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | shares | shares.index | App\Http\Controll ers\[email protected] | web | | | POST | shares | shares.store | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | shares/create | shares.create | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | shares/{share} | shares.show | App\Http\Controll ers\[email protected] | web | | | PUT|PATCH | shares/{share} | shares.update | App\Http\Controll ers\[email protected] | web | | | DELETE | shares/{share} | shares.destroy | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | shares/{share}/edit | shares.edit | App\Http\Controll ers\[email protected] | web | | | GET|HEAD | update | update.index | App\Http\Controll ers\[email protected]@index | web | | | POST | update | update.store | App\Http\Controll ers\[email protected]@store | web | | | GET|HEAD | update/create | update.create | App\Http\Controll ers\[email protected]@create | web | | | GET|HEAD | update/{update} | update.show | App\Http\Controll ers\[email protected]@show | web | | | PUT|PATCH | update/{update} | update.update | App\Http\Controll ers\[email protected]@update | web | | | DELETE | update/{update} | update.destroy | App\Http\Controll ers\[email protected]@destroy | web | | | GET|HEAD | update/{update}/edit | update.edit | App\Http\Controll ers\[email protected]@edit | web | +--------+-----------+----------------------+----------------+------------------ -----------------------------------+--------------+

This is the output, it doesnt work so far.

28 May
3 weeks ago

wuschelino22 left a reply on Edit Blade View

@JLRDW - Please give me a link for the tutorials. Thank you very much

wuschelino22 started a new conversation Update With CRUD

Hallo, i want to Update my SQL Databade via CRUD (Update)

This is my Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use View;
use App\Url;
use App\Categorie;


class ShareController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $shares = Url::all();
        $categories = Categorie::all();

        return view('index', compact('shares', 'categories'));

        //**Holt alle benötigten Daten für die Indexseite aus den beiden Datenbanken */
}


    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Categorie::all();
    
        return view('create', compact('categories'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

             $share = new Url([
            'name' => $request->get('name'),
            'urls'=> $request->get('urls'),
            'categorie_id'=> $request->get('categorie_id')
          ]);
          $share->save();
          return back();
    }

    /**
     * Display the specified resource. 
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit ($id)

    {
       
        $shares = Url::findOrFail($id);
        $categories = Categorie::get();  

        return view('edit', compact('shares'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
     
      $share = Url::find($id)([
            'name' => $request->get('name'),
            'urls'=> $request->get('urls'),
            'categorie_id'=> $request->get('categorie_id')
          ]);
          $share->save();
          return back();
             

    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function search(Request $request)
    {
 

    $urls = Url::where('name', $request->get('search'))
    ->orWhere('name', 'like', '%' . $request->get('search') . '%')->get();

    $shares = $urls;

    $categories = Categorie::whereIn('id', $shares->pluck('categorie_id'))->get();

    return view('index', compact('shares', 'categories'));


    }

    
}



And this is my EditBlade

@extends('layout')

@section('content')




<div class="panel panel-default">
      <div class="panel-heading">
      
      </div>
      <div class="panel-body">
    <form class="form-horizontal" role="form" method="POST" action="{{ route('shares.update', $shares->id) }}">
    @csrf
       
    <fieldset>
            <div class="form-group">
            <label for="firstname" class="col-md-2 control-label">Name:</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $shares->name }}" name="name" placeholder="First Name">
            </div>
          </div>

          <div class="form-group">
            <label for="lastname" class="col-md-2 control-label">Url:</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $shares->urls }}" name="urls" placeholder="Last Name">
            </div>
          </div>
          <button type="POST" class="btn btn-primary" action="{{ route('shares.update', $shares->id) }}">Update</button>


      </form>
     </div>
    </div>
  </div>

And this my web.php

Route::resource('shares', 'ShareController');

Route::get('create', '[email protected]');

Route::get('/', '[email protected]');

Route::post('search', '[email protected]');

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

Route::get('update', '[email protected]');

I get the follow Error Message what do i wrong ?

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.

Thank you very much

23 May
1 month ago

wuschelino22 left a reply on Edit Blade View

@FTIERSCH - Now it look good :-P thank you very much

wuschelino22 left a reply on Edit Blade View

@TY - Hello now i have change my Edit Blade to this:

@extends('layout')

@section('content')




<div class="panel panel-default">
      <div class="panel-heading">
      
      </div>
      <div class="panel-body">
        


      <!--  <form class="form-horizontal" action="{{ route('shares.edit', ['id' => $shares->id]) }}" method="POST">
          {{ csrf_field() }}-->






    <form class="form-horizontal" role="form" method="POST" action="{{ url('shares', $shares->id) }}">
    {{ csrf_field() }}
    {{ method_field('PATCH') }}

        <fieldset>

          <div class="form-group">
            <label for="firstname" class="col-md-2 control-label">First Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $shares->name }}" name="firstname" placeholder="First Name">
            </div>
          </div>

          <div class="form-group">
            <label for="lastname" class="col-md-2 control-label">Last Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $shares->urls }}" name="lastname" placeholder="Last Name">
            </div>
          </div>

        
        </fieldset>
      </form>
     </div>
    </div>
  </div>













<!--

<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Edit Profile</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ url('edit') }}"> Back</a>
</div>
</div>
</div>
@if ($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

@foreach ($shares as $share)

<form action="{{ url('edit', $share->id) }}" method="POST">
@csrf
@method('PUT')

@endforeach
-->

But i got also the error message:

Trying to get property 'id' of non-object (View: C:\xampp\htdocs\Linkliste\resources\views\edit.blade.php)

This ist my Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use View;
use App\Url;
use App\Categorie;


class ShareController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $shares = Url::all();
        $categories = Categorie::all();

        return view('index', compact('shares', 'categories'));

        //**Holt alle benötigten Daten für die Indexseite aus den beiden Datenbanken */
}


    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Categorie::all();
    
        return view('create', compact('categories'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

          $share = new Url([
            'name' => $request->get('name'),
            'urls'=> $request->get('urls'),
            'categorie_id'=> $request->get('categorie_id')
          ]);
          $share->save();
          return back();
    }

    /**
     * Display the specified resource. 
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit ($id)

    {
       
        $shares = Url::findOrFail($id);
        $categories = Categorie::get();  

        return view('edit', compact('shares'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
     
     Url::find($id)->update($request->all());
      return redirect()->route('index')->with('success','Post update successfully');

    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function search(Request $request)
    {
 

    $urls = Url::where('name', $request->get('search'))
    ->orWhere('name', 'like', '%' . $request->get('search') . '%')->get();

    $shares = $urls;

    $categories = Categorie::whereIn('id', $shares->pluck('categorie_id'))->get();

    return view('index', compact('shares', 'categories'));


    }

    
}

Thank you very very much

wuschelino22 left a reply on Edit Blade View

@TY - Now i have done this , but also the same error.

public function edit ($id)

    {
       
        $shares = Url::findOrFail($id);
        $categories = Categorie::get();  

        return view('edit', compact('shares'));
    }
22 May
1 month ago

wuschelino22 left a reply on Edit Blade View

@JLRDW - i have watch a lot of crud tutorial befor i put my question here in the channel. No tutorial help me sorry:-(

wuschelino22 left a reply on Edit Blade View

@TY - In my ShareControler i have edit it in :

public function edit (Request $request, $id)

    {
       
        $shares = Url::findOrFail($id);
        $categories = Categorie::get();  

        return view('edit', compact('shares'));
    }

but i got the error message again:

Trying to get property 'id' of non-object (View: C:\xampp\htdocs\Linkliste\resources\views\edit.blade.php) Previous exceptions Trying to get property 'id' of non-object (0)

wuschelino22 left a reply on Edit Blade View

@TRAY2 - Also the same error message :-( :-(

wuschelino22 left a reply on Edit Blade View

@TRAY2 - I have done it but the same error message. Do you have another idea ? Thank you

wuschelino22 left a reply on Edit Blade View

@TRAY2 - Thank you i have done it look: My Edit Blade:

@extends('layout')

@section('content')




<div class="panel panel-default">
      <div class="panel-heading">
      
      </div>
      <div class="panel-body">
        <form class="form-horizontal" action="{{ route('shares.edit', ['id' => $shares->id]) }}" method="POST">
          {{ csrf_field() }}
        <fieldset>

          <div class="form-group">
            <label for="firstname" class="col-md-2 control-label">First Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $shares->name }}" name="firstname" placeholder="First Name">
            </div>
          </div>

          <div class="form-group">
            <label for="lastname" class="col-md-2 control-label">Last Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $shares->urls }}" name="lastname" placeholder="Last Name">
            </div>
          </div>

        
        </fieldset>
      </form>
     </div>
    </div>
  </div>

And the ShareController:

 public function edit (Request $request, $id)

    {
       
        $shares = Url::findOrFail($id);
        $categories = Categorie::all();        

        return view('edit', compact('shares'));
    }

But now i get this message again when i click on the editbutton in index.blade:

C:\xampp\htdocs\Linkliste\storage\framework\views\2bc79337464b3814b5f964f1ec46b8cf5d15e923.php

wuschelino22 left a reply on Edit Blade View

@TRAY2 - When i do this, i get the follow error message:

ErrorException (E_ERROR)
Undefined variable: share (View: C:\xampp\htdocs\Linkliste\resources\views\edit.blade.php)
Previous exceptions
Undefined variable: share (0)

wuschelino22 left a reply on Edit Blade View

@FTIERSCH - Thank you very much. Now i get the follow error message.

</div>
<div class="pull-right">
<a class="btn btn-primary" href="<?php echo e(url('edit')); ?>"> Back</a>
</div>
</div>
</div>
<?php if($errors->any()): ?>
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
<?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<li><?php echo e($error); ?></li>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</ul>
</div>
<?php endif; ?>
 
<?php $__currentLoopData = $shares; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $share): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
 
<form action="<?php echo e(url('edit', $share->id)); ?>" method="POST">
<?php echo csrf_field(); ?>
<?php echo method_field('PUT'); ?>
 
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
-->
 
 
<?php $__currentLoopData = $shares; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $share): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
 
 
<div class="panel panel-default">
      <div class="panel-heading">
      
      </div>
      <div class="panel-body">
        <form class="form-horizontal" action="<?php echo e(route('shares.edit',$share->id)); ?>" method="POST">
          <?php echo e(csrf_field()); ?>
 
        <fieldset>
 
Arguments
"Trying to get property 'id' of non-object (View: C:\xampp\htdocs\Linkliste\resources\views\edit.blade.php)"

That is my edit.blade

@extends('layout')

@section('content')

@foreach($shares as $share)


<div class="panel panel-default">
      <div class="panel-heading">
      
      </div>
      <div class="panel-body">
        <form class="form-horizontal" action="{{ route('shares.edit', ['id' => $share->id]) }}" method="POST">
          {{ csrf_field() }}
        <fieldset>

          <div class="form-group">
            <label for="firstname" class="col-md-2 control-label">First Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $share->name }}" name="firstname" placeholder="First Name">
            </div>
          </div>

          <div class="form-group">
            <label for="lastname" class="col-md-2 control-label">Last Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $share->urls }}" name="lastname" placeholder="Last Name">
            </div>
          </div>

        
        </fieldset>
      </form>
     </div>
    </div>
  </div>





@endforeach

I dont no what this error mean i have read a lot in the internet but i cant use it in my project to solve the problem.

Thank you

wuschelino22 started a new conversation Edit Blade View

Hello, i want to build a edit view that only shows the data for the one i want to edit in my edit.blade.php I use the follow foreach at the moment on my blade. But it only shows me every thing.

@foreach($shares as $share)


<div class="panel panel-default">
      <div class="panel-heading">
      
      </div>
      <div class="panel-body">
        <form class="form-horizontal" action="{{ route('shares.edit',$share->id) }}" method="POST">
          {{ csrf_field() }}
        <fieldset>

          <div class="form-group">
            <label for="firstname" class="col-md-2 control-label">First Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $share->name }}" name="firstname" placeholder="First Name">
            </div>
          </div>

          <div class="form-group">
            <label for="lastname" class="col-md-2 control-label">Last Name</label>

            <div class="col-md-10">
              <input type="text" class="form-control" value="{{ $share->urls }}" name="lastname" placeholder="Last Name">
            </div>
          </div>

        
        </fieldset>
      </form>
     </div>
    </div>
  </div>

But i only want that it show me this one wich i have selected with the edit button on the index.view Here is the index view:

@extends('layout')

@section('content')
<style>
a:link{color:#000;}


  .uper {
    margin-top: 20px;
  
  }

  .card {
    width: 80%;
    float: right;
    background-color: #f7f7f7;
    margin-right: 50px;
  }

  .nav {
    width: 17%;
    float: left;
    background-color: #f7f7f7;
    height:80%;
    padding-top: 20px;
  padding-right: 20px;
  padding-bottom: 20px;
  padding-left: 20px;

  }

  .accordion {
    padding-top: 20px;
  padding-right: 20px;
  padding-bottom: 20px;
  padding-left: 20px;


  }


.navbar-expand-lg {

  padding-top: 20px;
  padding-right: 60px;
  padding-bottom: 20px;
  padding-left: 20px;
  height: 8%;
  border: 1px solid black;
}


</style>

<!-- Navigationsleiste -->

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="{{url('/')}}">IBP1 - Linkliste</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
  Link hinzufügen
</button>
      </li>
 </ul>

    <form class="form-inline my-2 my-lg-0" action="/search" method="post">
    {{ csrf_field() }}
      <input class="form-control mr-sm-2" name="search" type="search" placeholder="Suchen" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Suchen</button>
    </form>
  </div>
</nav>






<!-- Accordion  -->
<div class="accordion" id="accordionExample">
@foreach ($categories as $categorie)

@foreach ($shares as $share)
    <a href="{{route('shares.edit', $categorie->id)}}" inputtype="hidden" class="btn btn-default" action="{{$categorie->id}}" name="data-name" style="position: absolute;
        right: 20;"  ><i class="fas fa-edit"></i></a>
@endforeach


<div class="cars">
    <div class="card-header" id="headingSix">
      <h2 class="mb-0">
        <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapse{{$categorie->id}}" aria-expanded="false" aria-controls="collapse{{$categorie->id}}" style="color: black">
        {{ $categorie->name}}
        </button>

        <!--
       <a href="{{ url('/edit') }}" class="btn btn-xs btn-info pull-right" input type="submit" value="{{$categorie->id}}" style="float: right; background-color: #3490dc">Edit</a>
        -->

      </h2>

    </div>
    <div id="collapse{{$categorie->id}}" class="collapse" aria-labelledby="heading{{$categorie->id}}" data-parent="#accordionExample">
      <div class="card-body">



    <!-- Einfügen der Daten in die Tabelle nach Kategorie ID -->
      @foreach($shares->where('categorie_id', $categorie->id) as $share)
     
 
      <a href='{{ $share->urls }}' style="color: black">{{ $share->name }}</a><br>


      <div>

      </div>
      @endforeach
      </div> 
    </div>
</div>       
        @endforeach
</div>





<!-- Modal Pushfenster Link hinzufügen -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Link hinzufügen:</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      
      <form method="post" action="{{ route('shares.store') }}">
      <div class="form-name">
              @csrf
              <label for="name">Link Name:</label>
              <input type="text" class="form-control" name="name"/>
          </div>
          <div class="form-adress">
              <label for="adress">Link Adresse:</label>
              <input type="text" class="form-control" name="urls"/>
              </div>
             
          <div class="form-kategorie">
              <label for="categorie">Kategorie:</label>
                   <option value='0' selected></option>
                   <select name='categorie_id' class='form-control'>
                                    <option value='0' selected></option>
                                    @foreach($categories as $categorie)
                                    <option value='{{ $categorie->id }}'>{{ $categorie->name }}</option>
                                    @endforeach
                                    </select>
                                       </div>
                                       <br>
                                       <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                       <button type="submit" class="btn btn-primary" action="{{ route('shares.store') }}">Hinzufügen</button>
                                       </form>
      <div class="modal-footer">
        
      </div>
    </div>
  </div>
</div>

Thats the web.php

Route::get('edit', '[email protected]');

An that is my [email protected]:

 public function edit(Request $request, $id)

    {
       
        $shares = Url::all();
        $categories = Categorie::all();        

        return view('edit', compact('shares'));
    }

Iam a absolutly beginner have read an whatch a lot in the internet. But i cant get the right solution :-( Thank you very much

16 May
1 month ago

wuschelino22 started a new conversation Value Button In Laravel View

Hallo i have created a accordion with the button edit and the value of the button ist my cateregory id from the sql table. here is the buttom:

''' div class="accordion" id="accordionExample"> @foreach ($categories as $categorie)

{{ $categorie->name}}
   <a href="{{ url('/edit') }}" class="btn btn-xs btn-info pull-right" input type="submit" value="{{$categorie->id}}" style="float: right; background-color: #3490dc">Edit</a>

  </h2>
</div>
<div id="collapse{{$categorie->id}}" class="collapse" aria-labelledby="heading{{$categorie->id}}" data-parent="#accordionExample">
  <div class="card-body">

''' now i want to work with this value of the button in the edit-view. the edit view should only shows my entrys from the database wich category id is like the button i click in the index view on my accordion.

Can someone help me ? at the moment when i click all the buttons on my index blade in the edit blade the only get the id->variable for the frist category:-(

Thank you

14 May
1 month ago

wuschelino22 started a new conversation Edit Function Crud

Hello , i want to build Laravel CRUD. And now i habe a Problem with the Edit function.

''' public function edit(Request $request)

{
    $shares = Url::all();
    return view('edit',compact('shares')); 
}

'''

My Index view is this:

'''

@foreach ($categories as $categorie)

{{ $categorie->name}}
  </h2>
  
</div>

<div id="collapse{{$categorie->id}}" class="collapse" aria-labelledby="heading{{$categorie->id}}" data-parent="#accordionExample">
  <div class="card-body">
 


<!-- Einfügen der Daten in die Tabelle nach Kategorie ID -->
@foreach($shares->where('categorie_id', $categorie->id) as $share)
  <a href='{{ $share->urls }}' style="color: black">{{ $share->name }}</a>
  
  <div type="button"  class="btn-primary float-right" onclick="location.href='{{ url('edit') }}'" value="$share->id" >Edit</div>

 
 
  <br>
  
  @endforeach
@endforeach ''' In the Accordion iam using Variables so i dont need so much code.

Now ich have build a EDIT-Button for every entry in the accordion from the Database.

I want to build an Edit view that only shows this entry on wich button i have pressed.

at the moment it only shows the first entry in the Database . I have check this with the following command.

''' @foreach($shares as $share) {{dd($share->name)}} @endforeach

10 May
1 month ago

wuschelino22 left a reply on Laravel Crud Edit

@MAUNG-C - Thank you and how can i check wich datas are availible in my edit.blade.php ?

wuschelino22 left a reply on Laravel Crud Edit

Sorry i dont understand it :-( can someone make a example for me with my datas? Thank you

09 May
1 month ago

wuschelino22 started a new conversation Laravel Crud Edit

Hello, i want to use Edit in CRUD for edit my Datas in the Database i have read the Documentation but i dont understand it. Can Someone help mit to solve my Problem?

here is my Crud Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use View;
use App\Url;
use App\Categorie;


class ShareController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $shares = Url::all();
        $categories = Categorie::all();

        return view('index', compact('shares', 'categories'));


}


    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Categorie::all();
    
        return view('create', compact('categories'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

          $share = new Url([
            'name' => $request->get('name'),
            'urls'=> $request->get('urls'),
            'categorie_id'=> $request->get('categorie_id')
          ]);
          $share->save();
          return back();
    }

    /**
     * Display the specified resource. 
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function search(Request $request)
    {
 

    $urls = Url::where('name', $request->get('search'))
    ->orWhere('name', 'like', '%' . $request->get('search') . '%')->get();

    $shares = $urls;

    $categories = Categorie::whereIn('id', $shares->pluck('categorie_id'))->get();

    return view('index', compact('shares', 'categories'));


    }

    
}

I want the edit Datas in the MYSQL Database wich is called URL hier is my Model File

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Url extends Model
{

    use Softdeletes;

    protected $fillable = [
    
        'name',
        'urls',
        'categorie_id'
    ];

    public function categorieName()
    {
        return $this->belongsTo('App\Categorie', 'categorie_id');
    }
    
}

Thank you so much

wuschelino22 left a reply on POP UP View Modal

@snapey i got it :-) it works perfect thank you very much

wuschelino22 left a reply on Search Function MYSQL

now it works fine thank you

wuschelino22 left a reply on Search Function MYSQL

@SERGIU17 - i have done it:

my app service provider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use View;
use App\Category;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
    View::share('categories',Category::all());

    }
}

My ShareController

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use View;
use App\Url;
use App\Categorie;


class ShareController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $shares = Url::all();
        $categories = Categorie::all();

        return view('index', compact('shares', 'categories'));


}


    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Categorie::all();
    
        return view('create', compact('categories'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {


          $share = new Url([
            'name' => $request->get('name'),
            'urls'=> $request->get('urls'),
            'categorie_id'=> $request->get('categorie_id')
          ]);
          $share->save();
          return view('create');
    }

    /**
     * Display the specified resource. 
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function search(Request $request)
    {
 

    $urls = Url::where('name', $request->get('search'))
    ->orWhere('name', 'like', '%' . $request->get('search') . '%')->get();

    $shares = $urls;

    return view('index', compact('shares'));





    }

    




}



and my index.blad.php

@extends('layout')

@section('content')
<style>
a:link{color:#000;}


  .uper {
    margin-top: 10px;
  
  }

  .card {
    width: 80%;
    float: right;
    background-color: #f7f7f7;
    margin-right: 50px;
  }

  .nav {
    width: 17%;
    float: left;
    background-color: #f7f7f7;
    height:90%;

  }

  .nav {
    

  }

</style>

<!-- Navigationsleiste -->

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">IBP1 - Linkliste</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
  Link hinzufügen
</button>
      </li>
 </ul>

    <form class="form-inline my-2 my-lg-0" action="/search" method="post">
        {{ csrf_field() }}
      <input class="form-control mr-sm-2" name="search" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

<br>





<!-- Accordion  -->
<div class="accordion" id="accordionExample">
@foreach ($categories as $categorie)

<div class="card">
    <div class="card-header" id="headingSix">
      <h2 class="mb-0">
        <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapse{{$categorie->id}}" aria-expanded="false" aria-controls="collapse{{$categorie->id}}" style="color: black">
        {{ $categorie->name}}
        </button>
      </h2>
    </div>
    <div id="collapse{{$categorie->id}}" class="collapse" aria-labelledby="heading{{$categorie->id}}" data-parent="#accordionExample">
      <div class="card-body">

    <!-- Einfügen der Daten in die Tabelle nach Kategorie ID -->
      @foreach($shares->where('categorie_id', $categorie->id) as $share)
      <a href='{{ $share->urls }}' style="color: black">{{ $share->name }}</a><br>
      @endforeach
      </div> 
    </div>
</div>       
        @endforeach
</div>


<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Link hinzufügen:</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      
      <form method="post" action="{{ route('shares.store') }}">
      <div class="form-name">
              @csrf
              <label for="name">Link Name:</label>
              <input type="text" class="form-control" name="name"/>
          </div>
          <div class="form-adress">
              <label for="adress">Link Adresse:</label>
              <input type="text" class="form-control" name="urls"/>
              </div>
             
          <div class="form-kategorie">
              <label for="categorie">Kategorie:</label>
                   <option value='0' selected></option>
                   <select name='categorie_id' class='form-control'>
                                    <option value='0' selected></option>
                                    @foreach($categories as $categorie)
                                    <option value='{{ $categorie->id }}'>{{ $categorie->name }}</option>
                                    @endforeach
                                    </select>
                                       </div>
                                       <br>
                                       <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                       <button type="submit" class="btn btn-primary" action="{{ route('shares.store') }}">Hinzufügen</button>
                                       </form>
      <div class="modal-footer">
        
      </div>
    </div>
  </div>
</div>

what is wrong ?

wuschelino22 left a reply on Search Function MYSQL

i have done this now. Now i get this messages:

Invalid argument supplied for foreach() (View: C:\xampp\htdocs\Linkliste\resources\views\index.blade.php)

wuschelino22 left a reply on Search Function MYSQL

@SERGIU17 - Thank you. I understand this but now i have this Error Message

Class 'App\Providers\View' not found

wuschelino22 left a reply on Search Function MYSQL

@ftiersch @sergiu17 sorry iam a absolutly beginner, can you explain me this better or give me a Possible solution ?

Tnak you

wuschelino22 left a reply on POP UP View Modal

@snapey Tnak you but now i have a error message.

Undefined variable: categories (View: C:\xampp\htdocs\Linkliste\resources\views\create.blade.php)

That is my create Blade

@extends('layout')

@section('content')
<style>
  .uper {
    margin-top: 40px;
  }
</style>



<div class="card uper">
  <div class="card-header">
    Link hinzufügen:
  </div>
  <div class="card-body">
    @if ($errors->any())
      <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
              <li>{{ $error }}</li>
            @endforeach
        </ul>
      </div><br />
    @endif
      <form method="post" action="{{ route('shares.store') }}">
          <div class="form-group">
              @csrf
              <label for="name">Link Name:</label>
              <input type="text" class="form-control" name="name"/>
          </div>
          <div class="form-group">
              <label for="price">Link Adresse:</label>
              <input type="text" class="form-control" name="urls"/>
          </div>
        
        
          <div class="form-group">
              <label for="quantity">Kategorie:</label>

          


              <select name='categorie_id' class='form-control'>
                                    <option value='0' selected></option>




                                    
                                    @foreach($categories as $categorie)
                                                <option value='{{ $categorie->id }}'>{{ $categorie->name }}</option>

                                                

                                            @endforeach

                                           
                                   
          </div>
          
      </form>

      <button type="submit" class="btn btn-primary" action="{{ route('shares.store') }}">Hinzufügen</button>

  </div>
</div>


@endsection

wuschelino22 started a new conversation Search Function MYSQL

Hello i want to bulid a search function. i use this code:

{{ csrf_field() }} Search

and my /search function is this

public function search(Request $request) {

$urls = Url::where('name', $request->get('search'))
->orWhere('name', 'like', '%' . $request->get('search') . '%')->get();

$shares = $urls;

return view('index', compact('shares'));

and this is my web.php

Route::post('search', '[email protected]');

i get the follow error message but i dont know where the variable is missing

rrorException (E_ERROR) Undefined variable: categories (View: C:\xampp\htdocs\Linkliste\resources\views\index.blade.php)

Thank you

wuschelino22 left a reply on POP UP View Modal

@snapey can you show me the action for me? Because i attempt it and it will not work :-(

wuschelino22 left a reply on POP UP View Modal

@snapey Thank you very much the problem was that i do not close the tag. Now i want to save my data into the database if i push the Save Change button. Wich Action i need for this in the button?

Thank you very much.

wuschelino22 started a new conversation POP UP View Modal

Hello i want to use a Modal for transfer Data in to my Database. Now i have create my POP-UP Windows but it doesnt work when i use variables.