Laravel From Scratch [Part 8] - Edit & Delete Data

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 217

  • @markonikolic7684
    @markonikolic7684 6 років тому +160

    if someone need this here is a tip: 'pull-right' it doesn't work with Bootstrap 4 so you want to use 'float-right'

  • @rexparker6011
    @rexparker6011 5 років тому +20

    PUT/DELETE are now allowed as form methods in Laravel v6.4.1:
    and the routes work fine this way also.
    in edit.blade.php
    {!! Form::open(['action' => ['PostsController@update', $post->id], 'method' => 'PUT']) !!}
    in show.blade.php
    {!! Form::open(['action' => ['PostsController@destroy', $post->id], 'method' => 'DELETE']) !!}

  • @danielalbert4077
    @danielalbert4077 6 років тому +10

    hey bro..from Kenya here..you made me well conversant with Laravel,Thank you for the tutorial..Imma add myself to your subscribed users as a token of appreciation.

  • @Maystro_eg
    @Maystro_eg 4 роки тому

    The Best Course ever for me, I traveled through UA-cam searching for Laravel Tuts, all i found are Hindi but also not suitable for me and too long, this one is the best !!!, thanks man

  • @MuhammadAshraf-lo7pp
    @MuhammadAshraf-lo7pp 6 років тому +2

    Hi Brad. I am from Pakistan..I got tears in my eyes dear when I gonna executes codes smoothly....I always pray for you brother...compact and reasonable series....thanks bro..Allah bless you always. Ameen

  • @Fehera85
    @Fehera85 6 років тому +3

    To keep the method even simpler, you could identify the post on the method construct.
    instead of
    public function destroy($id) {
    }
    you could use
    public function destroy(Post $id) {
    }
    This replaces the $post = Post::find($id);
    By the way, your tuts are awesome. Keep it up mate!

  • @Osteele
    @Osteele 7 років тому +1

    This is the part where it gets a little confusing for noobs like me. That being said, this series is pretty amazing. I think that your delivery is spot on. Thank you so much for sharing your time and knowledge with us. Much appreciated. Peter

  • @blank001
    @blank001 5 років тому +1

    Have to say this is the best Laravel series there is. And I have tried 2 series earlier to this and just left them in the middle because they were either boring or way to fast, to my liking.

  • @mirzasisic
    @mirzasisic 6 років тому +32

    For those using Bootstrap 4 it's float-right instead of pull-right.

    • @ajmalthedeveloper7381
      @ajmalthedeveloper7381 4 роки тому

      This would be the full line of code:
      {!!Form::open(['action' => ['App\Http\Controllers\PostsController@destroy', $post->id], 'method' => 'POST', 'class' => 'float-right'])!!}
      StackOverFlow:
      stackoverflow.com/questions/47121605/postscontrollerdestroy-not-defined-in-laravel/64236027#64236027

    • @eephilosophy
      @eephilosophy 3 роки тому

      Thank You.

  • @bahnimanborah
    @bahnimanborah 6 років тому +3

    Brad,
    God bless you ! These tutorials are super easy to understand and up to the topic ! loving this !

  • @diaassada
    @diaassada 5 років тому +2

    3:46
    Using ck-editor form you actually can use 'method'=>' _PUT_ ' in place of 'method'=>' _POST_ ' instead of adding a __method_ hidden field. It will be automatically spoofed by sending a _method hidden field along with the submitted data.

    • @vellioth
      @vellioth 4 роки тому

      thank you!
      just wanna add that you can also do the same thing with delete

  • @TheSgrunder
    @TheSgrunder 5 років тому +2

    -c copies an entire line when nothing is selected (equal to yy in vi)
    -v pastes the line again above the cursor (equal to p in vi)
    -x deletes an entire line (equal to dd in vi)
    those commands makes editing so much faster
    btw... great videos

    • @quantumcd1045
      @quantumcd1045 4 роки тому

      -x cuts the line, you'll be able to paste it after you -x, thanks for the helpful advice however, very useful.

  • @shahrozeali6075
    @shahrozeali6075 6 років тому +2

    Your videos are great no doubt and i love the way of how you explain things. It makes Laravel much more easier. Long Live Pal.

  • @U32-w7f
    @U32-w7f 5 років тому +3

    clean and simple as Laravel. Great tutorial. Thank you, Brad.

  • @djsamke384
    @djsamke384 5 років тому +7

    The code below works fine dont need to add that hidden form thng
    Edit Post
    {!! Form::open(['action' => ['PostsController@update', $post->id], 'method' => 'PUT']) !!}
    {{ Form::label('title', 'Title', ) }}
    {{ Form::text('title', $post->title, ['class' => 'form-control', 'placeholder' => 'Title']) }}

    {{ Form::label('body', 'Body', ) }}
    {{ Form::textarea('body', $post->body, ['class' => 'form-control', 'placeholder' => 'Body', 'id' => 'article-ckeditor', 'style' => 'resize:none;']) }}
    {{ Form::submit('Submit', ['class' => 'btn btn-success']) }}
    {!! Form::close() !!}

    • @chamannarved6046
      @chamannarved6046 5 років тому

      Thanks 😊 bro ......👍👍

    • @duckyeah896
      @duckyeah896 5 років тому

      what is the different btw?

    • @j4878
      @j4878 4 роки тому

      @@duckyeah896 PostsController@update

  • @xseman
    @xseman 6 років тому +14

    You can use new Laravel directives to generate the _method input, like this
    @method('PUT')
    @csrf

  • @bmxchamp4
    @bmxchamp4 6 років тому +9

    I know this is old, but if you're like me you can't stand that the application redirects to the post list after creating and updating posts. If you're in the same boat, update your return line in the store method in PostsController.php to:
    return redirect()->route('posts.show', ['post' => $post->id])->with('success', 'Post created!');
    and also update your return line in the update method to:
    return redirect()->route('posts.show', ['post' => $id])->with('success', 'Post updated!');

    • @sasajovicic2384
      @sasajovicic2384 6 років тому +1

      I don't think that would work... If you want to have your application redirects to the newly created post, just add the id from the Post object to the URL:
      return redirect('/posts/'.$post->id)->with('success', 'Post Created');
      And if you want to do the same thing with the Update controller:
      return redirect('/posts/'.$post->id)->with('success', 'Post Updated');

    • @richmondmartinez170
      @richmondmartinez170 6 років тому

      They are both working anyways.

    • @OskarCeso
      @OskarCeso 6 років тому

      @@sasajovicic2384 what you think is irrelevant. If you want to be helpful then test it and THEN see if it works or not. Because in this case it works just fine and is actually the recommended way of doing this (see laravel documentation)

    • @hidayatnoradzmanhisham9726
      @hidayatnoradzmanhisham9726 5 років тому

      It's works very well. Thanks in advanced but I had one question, why I can't use this way 'posts/show'? because I get an error when used this way. I must used this way 'posts.show' and no errors.

    • @kiranojha8811
      @kiranojha8811 5 років тому

      Nice man but I only used this on edit method

  • @cecironalejoiii7680
    @cecironalejoiii7680 4 роки тому +2

    In laravel 6 Laravel Collective, you can directly use
    {!! Form::open(['method' => 'PUT', 'action' => ['PostsController@update', $post->id] ]) !!}
    PUT and DELETE methods will now be spoofed automatically

    • @mrbale1815
      @mrbale1815 4 роки тому

      how you got html forms working on laravel 6?

    • @cecironalejoiii7680
      @cecironalejoiii7680 4 роки тому

      @@mrbale1815 just put the tags on the blade. And if u want to retain the value then use value="{{ old(name) }}"

    • @HashimAziz1
      @HashimAziz1 3 роки тому

      Excellent, thank you

  • @manthrarasstogi378
    @manthrarasstogi378 4 роки тому

    if you are getting The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE. then all you can do is
    {!!Form::hidden('_method','PUT')!!}
    use this instead of
    {{Form::hidden('_method','PUT')}}
    .
    the first one works well

  • @pooriam2628
    @pooriam2628 5 років тому +5

    if someone has problem with the form 'action' and it doesn't work, you should use 'url' instead of action.

  • @bohem7298
    @bohem7298 5 років тому +11

    in version 5.8
    {{FORM::hidden('_method','xxxx')}} is no need to use anymore

  • @JasonJohnsonMa
    @JasonJohnsonMa 6 років тому

    Another great one. You need to have a tv show for nerds. love it.

  • @albertgarcia6483
    @albertgarcia6483 6 років тому +1

    great series sir! i learned a lot from your videos. we're hoping that you can make more vid from using chartJs, Js, Ajax in laravel. THank you so much!

  • @gcooper642
    @gcooper642 5 років тому

    Very helpful. Thank you. I've spent all morning looking for a way to do this!

  • @ghazanferanwar2467
    @ghazanferanwar2467 6 років тому +1

    The class 'pull-right' has been replaced by 'float-right'.So must change in order to obtain same as: "7:25 in video"

  • @jericdylan9560
    @jericdylan9560 7 років тому

    i just want to say thanks man. it really works all your tutorial for me.

  • @esraasalah8012
    @esraasalah8012 5 років тому

    I'm soooo in love of this tutorial, amazing explanation Brad..thank u bro

    • @teenmastr
      @teenmastr 5 років тому +1

      Yes indeed. It's amazing!

  • @kamaldeepak418
    @kamaldeepak418 5 років тому +2

    Undefined variable: post (View: C:\xampp\htdocs\lsapp
    esources\views\posts\show.blade.php) get this after edit post

    • @168severi
      @168severi 5 років тому

      Edit Post
      {!! Form::open(['action' => ['PostsController@update', $post->id], 'method' => 'PUT']) !!}

      {{ Form::label('title', 'Title', ) }}
      {{ Form::text('title', $post->title, ['class' => 'form-control', 'placeholder' => 'Title']) }}


      {{ Form::label('body', 'Body', ) }}
      {{ Form::textarea('body', $post->body, ['class' => 'form-control', 'placeholder' => 'Body', 'id' => 'article-ckeditor', 'style' => 'resize:none;']) }}

      {{ Form::submit('Submit', ['class' => 'btn btn-success']) }}
      {!! Form::close() !!}
      this was posted somewhere in the comments that fixed the problem for me.

    • @julianlaci5421
      @julianlaci5421 5 років тому

      @@168severi Do laravel collective forms still work? Finding these lectures difficult because laravelcollective website is down.

    • @168severi
      @168severi 5 років тому

      @@julianlaci5421 i dont think they do, you need to work around them and look around a bit sadly when following these

  • @zigggen
    @zigggen 6 років тому +3

    For those :: pull-right doesn't work USE THIS CODE
    Edit
    {!!Form::open(['action' => ['PostsController@destroy', $post->id, 'method' => 'POST', 'class' => 'float-right']])!!}
    {{Form::hidden('_method', 'DELETE')}}
    {{Form::submit('Delete', ['class' => 'btn btn-danger float-right'])}}
    {!!Form::close()!!}

  • @zeeshanmehdi3994
    @zeeshanmehdi3994 5 років тому

    bro your are love you made this so simple i have been able to create live football matches fixtures website watching your videos

  • @MustafaBirsoz
    @MustafaBirsoz 4 роки тому +1

    Thanks man

  • @basantakc2168
    @basantakc2168 7 років тому +23

    4 more to go. Easy to follow. :) .

  • @caiqueandrade6259
    @caiqueandrade6259 6 років тому +2

    Your videos are insane! Keep it up

  • @MilexCzechPlayer
    @MilexCzechPlayer 7 років тому +4

    Nice! But i have a question. Why is there a Form:hidden() method. I did not understand. Thanks for explanation!

    • @cxcats
      @cxcats 7 років тому +5

      The html form tag has only 'GET' or 'POST' these two method.
      stackoverflow.com/questions/8054165/using-put-method-in-html-form

    • @whackablemole
      @whackablemole 5 років тому

      If you use the new replacement for the Laravel Collective forms, you get all the same functionality but don't have to worry about spoofing these methods anymore. It supports PUT and DELETE straight out of the box now. :)

  • @Spurtas
    @Spurtas 6 років тому +3

    edit page doesn't seem to open.. hmmm, trying to debug and find how to fix it.

  • @pichmongkol168
    @pichmongkol168 3 роки тому

    Great video, thanks.

  • @wiscatbijles
    @wiscatbijles 6 років тому +1

    So the /postst/{id}/edit route is a default route when we do "php artisan make:controller PostsContoller --resource"? Because I was surprised it just worked like this.

  • @nanouk218
    @nanouk218 6 років тому +1

    Awesome tutorial!

  • @Npb10
    @Npb10 4 роки тому

    Thank you my friend!

  • @janinesantos7115
    @janinesantos7115 5 років тому +3

    Status Code: 405 Method Not Allowed message: "The PUT method is not supported for this route. Supported methods: GET, HEAD, POST."
    I kept getting this error so I removed the form hidden put but it worked just fine. Is this okay?

  • @javedapple1
    @javedapple1 7 років тому

    Very nice tutorial. Easy to follow. Keep it up :)

  • @korokoV23
    @korokoV23 3 роки тому +1

    Now in Laravel 8 we do not need to use the hidden method for put & delete we can use it directly

  • @sangeeth810
    @sangeeth810 4 роки тому

    excellent work

  • @shaneabutan6158
    @shaneabutan6158 5 років тому +1

    Anyone who gets '$post->title' and '$post->body' on the edit fields:
    edit.blade.php
    make sure to remove the ' ' on your $post->title and same goes to the body...

    • @bahadur2968
      @bahadur2968 4 роки тому

      why?

    • @morgane1762
      @morgane1762 4 роки тому

      Thanks very much, surprised more people didn't have this issue

  • @GamerL3INADz
    @GamerL3INADz 7 років тому +2

    Awesome videos!!

  • @hillaryyambao156
    @hillaryyambao156 6 років тому +1

    if you're receiving the error of Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException or just whenever you click the delete or edit button and it does not redirect you to another route then you can change the
    {!! Form::open(['action' => ['PostsController@update', $post->id], 'method'=> 'POST']) !!}
    to:
    {!!Form::model($post, array('method' => 'PUT', 'route' => array('posts.update', $post->id)))!!}
    also applies to the delete/destroy
    hope it helps

    • @erichjordaan8864
      @erichjordaan8864 5 років тому

      Thank you so much, the previous method with form was working and then after a update nothing, anywho your solution worked perfect thanks

  • @jessieaguiao
    @jessieaguiao 7 років тому

    great video, i learned a lot from you. thanks much.

  • @reesgargi
    @reesgargi 6 років тому +2

    Is "spoofing" the best thing to do?

  • @joskarhernandez8373
    @joskarhernandez8373 6 років тому

    If you're following this tutorial at the time that i'm writting this, you may have an error when creating the form and passing the post's id, it will throw you a missing url parameters or something like that, to solve it you've to pass it in array form like this: {!! Form::open(array('action' => array('PostsController@update', $post->id), 'method'=>'POST')) !!}.
    You can check the documentation web page to see it: laravel.com/docs/4.2/html#opening-a-form

  • @asmaamuhammed5477
    @asmaamuhammed5477 6 років тому +2

    I want to display old value when updating,how?

  • @ozancansel
    @ozancansel 6 років тому

    {!!Form::open(['action' => ['PostsController@destroy' , $post->id] , 'method' => 'DELETE' , 'class' => 'pull-right'])!!}
    {!!Form::open(['action' => ['PostsController@destroy' , $post->id] , 'method' => 'DELETE' , 'class' => 'pull-right'])!!}
    Specifying method in Form::open as a 'DELETE' or 'PUT' is much more logical i think. Specifying as a hidden field can be confusing

  • @mohammedrayyan3029
    @mohammedrayyan3029 5 років тому +2

    hi sir i like ur lectures
    sir in CRUD i have one doubt
    i face an error "undefined variable "id" while working with destroy method
    i copied similar to ur lecture
    pls reply for this

    • @sujoysarkar4246
      @sujoysarkar4246 4 роки тому

      i am having the same error !! have you fixed it?

  • @MafazaSPutra
    @MafazaSPutra 6 років тому +1

    Please help...,
    "Class 'Collective\Html\HtmlServiceProvider' not found"

  • @EDDIEcodename47
    @EDDIEcodename47 6 років тому

    If you're gettin' "Uncaught TypeError: Cannot read property 'getEditor' of undefined
    at a (ckeditor.js:322)
    at Object.CKEDITOR.replace (ckeditor.js:326)
    at 6:75" error where something isn't defined, just put script tags with ckeditor in edit view and not in app layout. Undefined doesn't hurt in this case, but who knows further down the course what troubles can protrude from it.

  • @JenineSilos
    @JenineSilos 6 років тому +1

    help! the marker class in my show page after editing text will not display the highlighted marker....but it displays the marker on the edit page....can someone help? thanks

  • @giancarlosgza
    @giancarlosgza 7 років тому +3

    Amazing videos :)

  • @larrycoleman9513
    @larrycoleman9513 2 роки тому

    I had a question about adding scripts and php code into the blog body area. It looks like you can only add certain html tags, like , and a few more in the source code. Even if you add, images when you go to edit and save those elements disappear. Is it a CKeditor problem or a database filter problem? Any fix for this?

  • @Franky1795
    @Franky1795 6 років тому +1

    How can I display errors (stack trace) like in the video? 8:37
    I have Laravel 5.6.23

  • @phynetruth
    @phynetruth 7 років тому +1

    Thanks for this wonderful tutorial, you are a wonderful teacher. but i have a little problem on this part with the @foreach($posts as $post) am getingt undefined variable error. Please help me. "Undefined variable: posts (View: C:\wamp\www\myapp
    esources\views\dashboard.blade.php)"

  • @168severi
    @168severi 5 років тому

    Re posting this here from someone else lower on the comments, so that people can see it more easily. This piece of code should fix the problem when getting an error after editing a post.
    Edit Post
    {!! Form::open(['action' => ['PostsController@update', $post->id], 'method' => 'PUT']) !!}

    {{ Form::label('title', 'Title', ) }}
    {{ Form::text('title', $post->title, ['class' => 'form-control', 'placeholder' => 'Title']) }}


    {{ Form::label('body', 'Body', ) }}
    {{ Form::textarea('body', $post->body, ['class' => 'form-control', 'placeholder' => 'Body', 'id' => 'article-ckeditor', 'style' => 'resize:none;']) }}

    {{ Form::submit('Submit', ['class' => 'btn btn-success']) }}
    {!! Form::close() !!}

    • @khalifmahdi
      @khalifmahdi 4 роки тому

      Strange enough, the hidden input to spoof a PUT request is no longer required this way. thanks man!

  • @karlomiguelperez4450
    @karlomiguelperez4450 4 роки тому

    Hi, regarding the notification of deletion of the post - mine does not show the bootstrap success notification (the green box above) upon redirecting to "/posts"; although the post is successfully removed. Tried if the pagination affects it but it doesn't.

  • @mbaljeetsingh
    @mbaljeetsingh 7 років тому +1

    You could have used Form::model instead of Form::open in the edit template

  • @jaikangammalangmei8271
    @jaikangammalangmei8271 6 років тому

    Can we do it without using resource in the route. ?? Custom edit and update without using the custom resource controller.

  • @jritzeku
    @jritzeku 4 роки тому

    I used 'method => PUT' @ 3:37 and works so didn't have to do the spoof request strategy. He said we cant use 'method=>PUT' but didn't really explain why. In fact this works for delete to so can just specify method as 'method' => 'DELETE' without doing the spoof request {{--{{Form::hidden('_method', 'DELETE')}}--}}. Perhaps this is ok with new laravel version.

  • @HashimAziz1
    @HashimAziz1 3 роки тому

    How can I avoid "PostsControllers@store\PostsController@destroy not defined" without having to explicitly type the full path to the controller in "action" every time?

  • @veenadanak559
    @veenadanak559 5 років тому

    Is it necessary to use form helper in blade?
    Can't we just write html for it?

  • @nisem0no
    @nisem0no 7 років тому +2

    Is there a reason why you aren't using the built in route function? Your links are hard coded which is yukky. :(

    • @devilmanscott
      @devilmanscott 7 років тому

      Once you get better, how you love to have full control over routes, Rails popularised the resource style of routes, how I hated it as routes and links got more inheritance, especially as sites got bigger.
      Also now I moved away from traditional routes, you know using the client instead of having the server do it, using mostly APIs now, loving the ability to use all the request verbs as-well.
      The very fact I can have just one endpoint in the server for every controller is wonderful, a large reason I moved away from resource style routes.

  • @vikastomar7206
    @vikastomar7206 4 роки тому +2

    bro how to update image

  • @ailosiri
    @ailosiri 2 роки тому

    Hey, how do I put it using regular forms?

  • @Barek04
    @Barek04 6 років тому

    I have problem with 'edit' part. I put values in form but it doesn't show proper values. It show values from just one user. Why?

  • @j4878
    @j4878 4 роки тому +2

    Hey 2020(under ecq) guys, 'PostsController@update'

  • @Fadwa40
    @Fadwa40 Рік тому

    k very usefull tutorial but how about just need to link two different sites like wordpress and prestashop whit laravell ?

  • @karthikr5033
    @karthikr5033 5 років тому

    in post->id id is not taking , instead of id it is displaying only character id not showing number. what to do ???

  • @johnedelmapa
    @johnedelmapa 6 років тому

    I have errors. Trying to get property of non-object (View: C:\laragon\www\unorfiles
    esources\views\posts\edit.blade.php)

  • @atmarmomand6334
    @atmarmomand6334 4 роки тому +2

    any one can solve this problum ??
    htmlspecialchars() expects parameter 1 to be string, array given (View: C:\xampp1\htdocs\lsappc
    esources\views\posts\edit.blade.php)

    • @rainfog_mzb
      @rainfog_mzb 4 роки тому

      I create form::open with this format
      {!! Form::open(['method' => 'PUT', 'action' => ['App\Http\Controllers\Postscontroller@update', $posy->id] ])!!}
      And finally, it worked in my place.

  • @quantumcd1045
    @quantumcd1045 4 роки тому

    for some reason when i add that delete form to the show page it breaks the app, i'm getting a 500 error back.

  • @KerishaStewart
    @KerishaStewart 6 років тому

    Hi, I am getting this error when trying to submit an edited post:
    Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
    I tried using the previous suggestions in the comments but they did not work for me. Used google as well and did not get through. If you can help, will appreciate it.
    Thank you.

  • @bastienm347
    @bastienm347 7 років тому +2

    I really don't see the point in spoofing the request and it seems I am not the only one. You should put an explanation somewhere. Could anyone explain it to me ?

    • @brokenblades1759
      @brokenblades1759 5 років тому

      So the point is HTML forms only allows you to use "GET" and "POST". However the route that ties to the update method in the post controller uses "PUT".
      You can't directly use "PUT" in the action attribute of the form tag. And if you leave it as POST and try to use it it will fail. Spoofing it is just a work around Laravel uses to get around this.

    • @metroid1117
      @metroid1117 5 років тому

      To elaborate on Broken Blade's response, a route for updating or deleting *could* be accessed via a POST request. However, for sake of syntactically meaningful code, it's best-practice to use PUT/PATCH and DELETE requests for routes that do those functions.

  • @sergiikharin1497
    @sergiikharin1497 7 років тому +4

    how can i get an alert msg before delete? tnx :)

    • @aldhieraimayazar2744
      @aldhieraimayazar2744 7 років тому +1

      You can add alert first on your controller is like delete confirmation right ? , before the Update sistem code line. or you can use javascript / jQuery trigerring on delete button. you can use this code reference , laravel-tricks.com/tricks/confirmation-before-deleting-an-item

    • @ruhlXXXL
      @ruhlXXXL 7 років тому +9

      this codes works for me
      {!!Form::open(['action' => ['PostsController@destroy', $post->id], 'method' => 'POST','onsubmit' => 'return confirmDelete()'])!!}
      {{Form::hidden('_method', 'DELETE')}}
      {{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
      {!!Form::close()!!}
      @endsection
      function confirmDelete() {
      var result = confirm('Are you sure you want to delete?');
      if (result) {
      return true;
      } else {
      return false;
      }
      }

    • @sergiikharin1497
      @sergiikharin1497 7 років тому +1

      tnx seems good for me also )

    • @saartaranus2123
      @saartaranus2123 6 років тому

      Thanks a lot :) , works great for me either.

    • @mohamedabdi8377
      @mohamedabdi8377 6 років тому

      this helped me. thank you so much

  • @goldensparrowmobile9924
    @goldensparrowmobile9924 5 років тому +1

    Undefined offset: 0 (View: /Applications/XAMPP/xamppfiles/htdocs/laravel/resources/views/posts/show.blade.php)

  • @sagebias2251
    @sagebias2251 6 років тому

    Why do you use links instead of buttons?

  • @lizempson2916
    @lizempson2916 5 років тому

    Loving course, however one problem. If i'm on create or edit page & choose to click 'BLOG' in navbar it cannot find the posts page. (Error:Trying to get property 'title' of non-object (View: C:\xampp\htdocs\lsapp
    esources\views\posts\show.blade.php). Don't understand why its looking for show.blade.php. The link works fine when moving along navbar but not from in or creating a post. Would be very grateful if anybody could point me to my error, many thanks

  • @bksadkri
    @bksadkri 5 років тому +1

    hey it says creating default object from empty value in edit.blade.php , can you please help ?
    $post = Post::find($id);
    // die(print_r($post));
    $post->title = $request ->input('title'); //error from here
    $post->description = $request ->input('description');
    die($post->title);
    $post->save();

    • @bksadkri
      @bksadkri 5 років тому

      its say undefined variable id

  • @sindhu1397
    @sindhu1397 6 років тому

    it says trying to get id of non object , can you please help ? in edit.blade.php

  • @elliotching1142
    @elliotching1142 5 років тому

    btn-default actually not existed during my time of trying, I've check my css file (\lsapp\public\css\app.css), btn-default is not found

    • @elliotching1142
      @elliotching1142 5 років тому

      I've used .btn-outline-secondary instead but pls suggest any alternative way to get btn-default

  • @MaishYeol
    @MaishYeol 3 роки тому

    when i do php artisan route:list i get this 'Target class [PostsController] does not exist.'

  • @wasekrahman6966
    @wasekrahman6966 6 років тому

    Hello! Can someone please help me? It seems like the files are not getting "updated" nor can the files be deleted. How do I fix this? Please advise!

  • @abdullahshoaib7377
    @abdullahshoaib7377 5 років тому

    i am using the destroy function to delete as in the video but it goes to store function when i press the delete button

    • @mykeeeliling
      @mykeeeliling 5 років тому

      check if your form action in show.blade.php is modified from store to destroy, should be ('PostsController@destroy')

  • @WhyCMD
    @WhyCMD 7 років тому +1

    Any had that this error and resolved it? Action App\Http\Controllers\PostsController@destroy not defined. (View: C:\xampp\htdocs\lsapp
    esources\views\posts\show.blade.php) Thanks.

  • @donald23333
    @donald23333 6 років тому

    How to fulfill edit function if form is dropdown list or datetime picker?
    Here are some of my code.
    Edit Tasks
    {!! Form::open(['action' => 'TasksController@store','method' => 'POST']) !!}
    {{Form::label('filetype','FileType')}}
    {{Form::select('filetype', array('pdf' => 'PDF', 'word' => 'Word','url' =>'URL',), 'pdf',['class'=>'form-control'])}}
    Please Select A
    Course Name
    @foreach($courses as $course)
    coursename == $course->id ? 'selected' : ''}}>{{ $course->coursename}}
    @endforeach

    {{Form::label('taskduetime','Task Due Date')}}
    {{Form::date('taskduetime', \Carbon\Carbon::now(),['class'=>'form-control'])}}

  • @kamaldeepak418
    @kamaldeepak418 6 років тому +2

    Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
    how to solve this?

    • @hillaryyambao156
      @hillaryyambao156 6 років тому +2

      if you're receiving the error of Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException or just whenever you click the delete or edit button and it does not redirect you to another route then you can change the
      {!! Form::open(['action' => ['PostsController@update', $post->id], 'method'=> 'POST']) !!}
      to:
      {!!Form::model($post, array('method' => 'PUT', 'route' => array('posts.update', $post->id)))!!}
      also applies to the delete/destroy
      hope it helps

    • @mehralnikhil
      @mehralnikhil 6 років тому

      I am still getting the error, is there any other way around it?

    • @mikekyto
      @mikekyto 6 років тому +1

      No, the problem is your DELETE function. Don't forget to use the underscore with the method. Example '_method'.

    • @fazrulafiq
      @fazrulafiq 5 років тому

      @@hillaryyambao156 thank you!

    • @bushwhack12
      @bushwhack12 5 років тому

      @@mikekyto thanks a lot!

  • @fahmired4556
    @fahmired4556 6 років тому +1

    i cant dellte file they said
    Call to a member function delete() on null

    • @junmojico5556
      @junmojico5556 5 років тому

      Check your action routing maybe you are not getting the id coz your getting null which means nothing to delete.

  • @lovkushsingh5200
    @lovkushsingh5200 6 років тому

    Downloaded you source code but its ending up with fatal error require(). Do you have any blog where i can solve my problem ?

    • @WTclub
      @WTclub 6 років тому

      Shouldn't it be request?

  • @rohitkulkarni3730
    @rohitkulkarni3730 3 роки тому

    after clicking on Delete button I am getting Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
    The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.
    can any one help me

  • @RIMJANESSOHMALOOG
    @RIMJANESSOHMALOOG 4 роки тому

    u lost me at 'editor', i couldn't get that working, i tried to revert back to not use it but now as soon as i click on the text field in create post, it's submitting, i'll do it from scratch again

  • @ArushaShahi
    @ArushaShahi 7 років тому

    My success message is not being shown. Please help!!

  • @RamadhaniShemahonge
    @RamadhaniShemahonge 4 роки тому

    Does CKeditor work in laravel 7.9. I tried several times installing with no luck

    • @Slada1
      @Slada1 4 роки тому

      Try tinymce. You can self host it for free and it is open source. Wordpress uses it too

  • @erickjaiedavid2264
    @erickjaiedavid2264 5 років тому

    How can i put confirmation on delete button?

    • @burhanaditya5072
      @burhanaditya5072 5 років тому

      use my code
      show.blade.php
      @extends('layout.app')
      @section('content')
      Back
      {{$post->title}}
      {!!$post->body!!}

      Ditulis pada {{$post->created_at}}
      Edit
      function ConfirmDelete()
      {
      var x = confirm("Are you sure you want to delete?");
      if (x)
      return true;
      else
      return false;
      }
      {!! Form::open(['action' => ['PostsController@destroy', $post->id], 'method' => 'POST', 'class' => 'float-right', 'onsubmit' => 'return ConfirmDelete()']) !!}
      {{Form::hidden('_method', 'DELETE')}}
      {{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
      {!!Form::close()!!}
      @endsection

  • @glufflix7208
    @glufflix7208 5 років тому

    If I want to removed confirmation , How can I do?

    • @burhanaditya5072
      @burhanaditya5072 5 років тому

      use my code
      show.blade.php
      @extends('layout.app')
      @section('content')
      Back
      {{$post->title}}
      {!!$post->body!!}

      Ditulis pada {{$post->created_at}}
      Edit
      function ConfirmDelete()
      {
      var x = confirm("Are you sure you want to delete?");
      if (x)
      return true;
      else
      return false;
      }
      {!! Form::open(['action' => ['PostsController@destroy', $post->id], 'method' => 'POST', 'class' => 'float-right', 'onsubmit' => 'return ConfirmDelete()']) !!}
      {{Form::hidden('_method', 'DELETE')}}
      {{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
      {!!Form::close()!!}
      @endsection

  • @w3healthdose
    @w3healthdose 4 роки тому

    hello guys, anyone have an idea why this happens?
    after i edit the post. i look on the database and i have tag on the edited body post that i did.
    it look like this in the database:
    id: 2
    title: Post Two
    body: This is post two
    created_at
    updated_at
    please help me with this.

    • @w3healthdose
      @w3healthdose 4 роки тому

      if a remove ckeditor scripts. when i edit the post it is doing fine.