Laravel 5.2 PHP Build a social network - Deleting Posts

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • Build a complete Social Network Web Application with PHP Laravel. In this video we will take care about deleting posts.
    Complete source code: github.com/msc...
    Complete Laravel-course on Udemy: www.udemy.com/... (Coupon: RUclips1)
    In this course we'll build a neat little social network and cover the basics of developing with Laravel.
    You can follow me on Twitter (@maxedapps), Facebook ( / academindchannel ) or visit our Website (www.academind.com).
    See you in the videos!

Комментарии • 41

  • @Micro7HD
    @Micro7HD 8 лет назад

    Hi,I have watched all this playlist videos of creating a social network with Laravel!
    I am really enjoying this tutorials, and I am codding this project at the same time.
    Keep with the good work, it's really helpfull, I am now waiting for the next videos in order to continue the project.
    Thanks for your videos!

    • @academind
      @academind  8 лет назад

      +Micro7HD
      Hi, it's great to hear that you like my content! Thank you!

  • @agilasadi5044
    @agilasadi5044 7 лет назад

    I created another page which can be accessed without logging in, but when i try to access it it says:
    Undefined variable: posts (View: C:\wamp64\www\ProjectName
    esources\views\PageName.blade.php)
    I asked the full question in stackoverflow and woul rly appreciate if anybody could help.
    stackoverflow.com/questions/41695880/laravel-trying-to-output-posts-but-controller-function-seem-to-work-wrong

  • @arthurclass4808
    @arthurclass4808 7 лет назад

    You are some legend ,thank you so much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:) :)

    • @academind
      @academind  7 лет назад

      So happy to read that artur! YOU and all the others supporting that channel in such an awesome way are legends :)

  • @christianchapoco5472
    @christianchapoco5472 2 года назад

    i love you holy shit

  • @jsever5517
    @jsever5517 8 лет назад

    Hi, i wonder how does deployment goes to actual server? in java app we just export our project as project.war file and just place the file in httpdoc folder restart the server and we are done and if its a springs+hibernate project our database tables are automatically created and ready to use! is that the same case with laravel framework too? or do we have too install laravel CLI on server to and run migrate command manually to create our tables? Thank You :)

    • @academind
      @academind  8 лет назад

      +JS Ever
      My deployment process looks like that, yes.
      Ship the files and run all migrations via artisan command line.

    • @jsever5517
      @jsever5517 8 лет назад

      +Mindspace that means i need to install composer CLI on server? what if my server doesn't have composer installed? is there an alternative to get that databse generated?

    • @academind
      @academind  8 лет назад +1

      No you don't need composer there at all. Artisan is run via PHP (therefore we use it with 'php artisan...'). So no need for composer

    • @jsever5517
      @jsever5517 8 лет назад

      +Mindspace Great i got it. Thanks a lot :)

  • @atefsoft
    @atefsoft 8 лет назад +1

    Successfully Deleted , Thank You Respected Sir

  • @narcojauy
    @narcojauy 8 лет назад +3

    Fantastic job. Perfect pacing for following along to recreate what you are doing. Great explanations. Thank you for posting this!

    • @academind
      @academind  8 лет назад

      +Ncojay
      Really awesome to read this, thanks a lot!

  • @parineetadas1366
    @parineetadas1366 7 лет назад

    Your tutorials are great! Thanks a lot :)
    But am getting an error.. After logging out, am unable to sign in.
    route page code:
    //SignIn
    Route::post('/signin',[
    'uses'=>'UserController@postSignIn',
    'as' =>'signin'
    ]);
    //Dashboard
    Route::get('/dashboard',[
    'uses'=>'PostController@getDashboard',
    'as' =>'dashboard'
    ]);
    //Logout
    Route::get('/logout',[
    'uses'=>'UserController@getLogout',
    'as' =>'logout'
    ]);
    Trying to get property of non-object (View: C:\xampp\htdocs\social_site
    esources\views\dashboard.blade.php)
    @foreach($posts as $post)
    {{ $post->body }}
    Posted By {{$post->user->first_name}} on {{$post->created_at}}

    Like |
    Dislike |
    Edit |
    Delete

    @endforeach
    Can you help me out?? Am badly stucked :(
    waiting for your reply.. Thanks

  • @devrkai7171
    @devrkai7171 8 лет назад

    Hi, Thanks for the great tutorial and btw i don't know why i get an error
    ErrorException in UrlGenerator.php line 307:
    Route [post.delete] not defined. (View: C:\xampp\htdocs\www\devrk_laravel
    esources\views\dashboard.blade.php)
    InvalidArgumentException in UrlGenerator.php line 307:
    Route [post.delete] not defined.
    Here's my PostController.php
    public function getDeletePost($post_id)
    {
    $post = Post::where('id', $post_id)->first();
    $post->delete();
    return redirect()->route('dashboard')->with(['message' => 'Successfully deleted']);
    }
    and this is my routes.php
    Route::get('/delete-post/{post_id}', [
    'uses' => 'PostController@getDeletePost',
    'name' => 'post.delete',
    'middleware' => 'auth'
    ]);
    and this is the dashboard.blade.php
    @foreach($posts as $post)
    {{ $post->body }}
    Posted by {{ $post->user->first_name }} on {{$post->created_at}}

    Like |
    Dislike |
    Edit |
    Delete

    @endforeach
    i've already check the codes 3rd time i even play back the video again again i didn't find what's wrong.
    btw im using the latest laravel 5.2 ? because i just installed it yesterday.
    God bless and more power.

    • @academind
      @academind  8 лет назад +1

      +Devrk ai
      Hi, I'm happy to hear that you are liking my videos! :)
      You have a little but important error in your routes.php file. Routes are named via the 'as' key, not 'name'.
      It should work once you change the route to look like this:
      Route::get('/delete-post/{post_id}', [
      'uses' => 'PostController@getDeletePost',
      'as' => 'post.delete',
      'middleware' => 'auth'
      ]);

    • @devrkai7171
      @devrkai7171 8 лет назад

      +Mindspace Wow srsly how dumm am i HAHA! why the heck i was using name on that o.O maybe i just got so tired haha thank you so much +Minspace

    • @academind
      @academind  8 лет назад

      Tiny things like these happen all the time...the worst thing is, that such errors take the longest to spot. ;)

  • @SaurabhIAm
    @SaurabhIAm 7 лет назад

    Hi +Mindspace, Thankyou for super great tutorials, I'm an absolute beginner to PHP MVC and your videos are helping me a lot. Just a quick question here, in route:
    Route::get('/deletepost/{post_id}',[
    'uses'=>'PostController@getDeletePost',
    'as'=>'post.delete',
    'middleware'=>['auth']
    ]);
    why do we have to pass {post_id} specifically in /deletepost/{post_id}? if I remove {post_id} its anyways going to redirect on /deletepost?post_id={id}. And in this case controller is giving me error "missing argument 1"
    Any way to pass the argument without specifying /deletepost/{post_id} in route?

  • @ouakouakilyes4384
    @ouakouakilyes4384 7 лет назад

    Hi first i'd like to thank you for the great job you are doing in here Thank you so much
    i've a question about the laravel framework or frameworks in general now im at the video #11 and i've understood almost all the features that you were talking about
    but the question that i want to ask is that we've studied many things in php such as how to write some SQL queries to connect into the DATABASE and to insert/update/delete posts and also how to rewrite our URLs using pure php code
    And now by using laravel everything is much simpler an faster so after mastering these powerful tools provided by laravel we will be able to do great things but the problem in other side we will forget the pure PHP codes that we were writing before
    So is it the case for all developers or i'm just seeing it from the wrong side?
    Thank you in advance

  • @yadunandanpillai2899
    @yadunandanpillai2899 7 лет назад

    Question: Why did you use a GET HTTP verb instead of DELETE? Doesn't using a delete route make more sense?

    • @academind
      @academind  7 лет назад

      You can't send DELETE requests by submitting a HTML form. (sidenote: you can with some tricks)

    • @yadunandanpillai2899
      @yadunandanpillai2899 7 лет назад

      When do DELETE, PUT, PATCH, and others apply to web programming then? Are they just API requests?

    • @academind
      @academind  7 лет назад

      Yes, you can use them when sending Ajax requests.

    • @yadunandanpillai2899
      @yadunandanpillai2899 7 лет назад

      Ah, thank you. Really appreciate your help sir.

  • @bhushangaikwad2208
    @bhushangaikwad2208 6 лет назад

    Laravel and admin lte crud plz

  • @Xirismenos
    @Xirismenos 7 лет назад

    Is not safe with get method to delete something. It can be hacked easily. Is not best practice.

    • @mitchelline
      @mitchelline 6 лет назад

      This man is a genius, stop pretending that you know more than him (jk lol, but he is a genius)

  • @manuelli_sebastian
    @manuelli_sebastian 8 лет назад

    Wouldn't be better to just change for example delete = 1 in database for history purposes? Btw 😁 excellent tutorials man!

    • @academind
      @academind  8 лет назад

      +Johny Manuelli
      Hi Johny,
      that's a valid point you're bringing up here. It really depends on the application, but of course this certainly is a better way of keeping the history/ backups is important.
      Under other circumstances this might not be needed. Very good suggestions though and definitely which you'll implement in such a way a lot.

    • @SebastianPerezG
      @SebastianPerezG 8 лет назад +2

      +Johny Manuelli Laravel has SoftDeletes , check the documentation here : laravel.com/docs/5.2/eloquent#soft-deleting

  • @PraveshKumar-ho1zx
    @PraveshKumar-ho1zx 5 лет назад

    great great great job !!!!!! thank you so much ...........

    • @academind
      @academind  5 лет назад

      Thanks so much Pravesh, really happy to read that you liked the video!

  • @Durlanac888
    @Durlanac888 8 лет назад

    One question: where is it specified which table the function shall fetch the data from?

    • @academind
      @academind  8 лет назад

      Laravel assumes a certain table naming. If your Model is named "User", then it assumes the table to be named "users" (lowercase, plural).

    • @Durlanac888
      @Durlanac888 8 лет назад

      +Mindspace That is very nice indeed. I knew that this framework does most of the heavy lifting, but assumption of names, that is new level of awesome. And again, great tutorials mate, keep up the good work!

    • @academind
      @academind  8 лет назад

      Thank you, I'll do my best! :)

  • @cheikhomarsow765
    @cheikhomarsow765 7 лет назад

    Thanks you !!!

    • @academind
      @academind  7 лет назад +1

      Thanks a lot for your comment Cheikh!

    • @cheikhomarsow765
      @cheikhomarsow765 7 лет назад

      I'm watching series and it's really cool, you explain very well