marioeid

marioeid

Member Since 4 Months Ago

cairo

Experience Points 4,110
Experience Level 1

890 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 32
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.

05 Feb
1 month ago

marioeid started a new conversation I Am Did The Tags To Posts Many To Many Relation Ship How To Input It In Form

what i want to do is to have a drop down list with some static options in it like the one in laracast when i am posting i have to select a channel how to do it inside my form that when he chooses this list element it will set the id equal to static id and the name equal to the static name

17 Jan
2 months ago

marioeid left a reply on Laravel Syntax In Vs Code

@NEOIGHODARO - it worked thanks

marioeid left a reply on Laravel Syntax In Vs Code

<div class="row">
                        <span class="circle">what's C++?<br></span>
                        <p>
                            c++ is an intermediate-level programming language which is known by it's fast performance and
                            it is also extension of the C language (another programming language) it can be written in two
                            ways "C style" or "object-oriented style." we will discus the oop style in detail
                        </p>
                        <span class="circle">what we need to start?<br></span>
                        <p>
                            before you start writting your code you need to use IDE stands for (Integrated development environment)
                            so watch this video
                            <a href="https://www.youtube.com/watch?v=3B4hPHZNtNw" target="_blank">install code blocks</a> it will show you how to download and install codeblocks and which compiler to be used
                        </p>
                        <span class="circle">Compiler <br></span>
                        A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses
                    </div>

this the code in vs it makes the color after it's or any single quote change till it meets another one

marioeid left a reply on Laravel Syntax In Vs Code

@JLRDW - i want to share a photo cause the code won't show the color change and i don't know how to share it

marioeid started a new conversation Laravel Syntax In Vs Code

i have a problem in vs code in

tag any single quote misses the color of the entire code and i don't know how to fix it and it also makes the code very hard to keep track off when i write words like it's or don't etc... it changes the color after the single quote till it finds another single quote it's like opening and closing for something

01 Jan
2 months ago

marioeid started a new conversation How To Tell The Database That This Comment Belongs To This Post In Storemethod (saving Stage)?

if i have a post and comments belong to that post and i am receiving the post id in store method in commentscontroller after associating the body and the title how to save the comment telling the database that this comment belongs to this post my store method

    public function store(Request $post)
      {
            $this->validate($post,['body'=>'required','title'=>'required']);
            $comment=new comments;
            $comment->body=request('body');
            $comment->title=request('title');
            $post->comments()->save($comment);
          // $post->id = $id;
            $response = array(
            'status' => 'success',
            'data' => $comment,
        );
            return response()->json($response); 
      }

marioeid left a reply on How To Pass The Csrf_token To My View Using Ajax Jquery

@MCSTEPP - yes it wasn't but i solved the issue i don't even need to use form if am using ajax to create or delete

18 Dec
3 months ago

marioeid left a reply on How To Use Append In Ajax Success Function To Add {{csrf_token()}}

@D9705996 - the data is right in inspect in chrome every data is right expect the token the token is undefined and i don't know why

marioeid started a new conversation How To Use Append In Ajax Success Function To Add {{csrf_token()}}

when i click post i append list inside it there's alink with data-token i want to set that value to {{csrf_token()}} but it doesn't work my success ajax call

$.ajax({
        // headers: {
        //     'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        //   }
        //   ,        
    url:'/createpost',
    type:'POST',
    data:$(".postform").serialize(),
    dataType: 'JSON',
   success:function(data)
   {
     
      if(data.status == "success"){


      $('#posts').append('<li class="arrow_box col-md-10 col-lg-10 offset-lg-1"><p><span id="title">'+data.data.title+'</span><br/><span id="body">'+data.data.body+'</span>               <br/><div class="info"><p> <div id="funform"> <div>'+data.data.created_at+'</div><a  class="fa fa-trash post_delete" data-token='+data.data.token+' data-id="'+data.data.id+'" data-url="/deletepost/'+data.data.id+'"></a><a class="fa fa-thumbs-up post_like"></a>   <a class="fa fa-comment post_comment"></a> <a class="fa fa-edit post_edit" </a></a>  </div> </p>  </div></p></li>');
      
      $('.close').click();
      $( '.postform' ).each(function(){
        this.reset();
    });
    
    }
     }
   ,error:function(data)
   {
     $('#errors').show();
     $('#errors').html('');
       var errors=data.responseJSON;
       $.each(errors,function(v,k)
       
       {
        $('#errors').append(v+"<br/>");

       }
       );
   }
   
    })



    });
    ```

marioeid left a reply on How To Pass The Csrf_token To My View Using Ajax Jquery

csrf_field isn't working i tried that before

marioeid left a reply on How To Pass The Csrf_token To My View Using Ajax Jquery

@PALAK27 - i am not asking how to pass to the data i am asking in the post function i am showing a new post how to put it in the view like

<a data-token="{{csrf_token()}}"></a>
17 Dec
3 months ago

marioeid started a new conversation How To Pass The Token To My View Using Ajax Jquery

the ajax function works but when i append i don't know how to pass the token to the jquery append function

 $('#post_create').on('click', function(e){
    
    //  var url=$(this).attr('action');
    //  var post=$(this).attr('method');
    e.preventDefault();
    //  var body=$('#body').val();
    //  var tilte=$('#title').val();
    $.ajax({
        // headers: {
        //     'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        //   }
        //   ,        
    url:'/createpost',
    type:'POST',
    data:$(".postform").serialize(),
    dataType: 'JSON',
   success:function(data)
   {
     
      if(data.status == "success"){


      $('#posts').append('<li class="arrow_box col-md-10 col-lg-10 offset-lg-1"><p><span id="title">'+data.data.title+'</span><br/><span id="body">'+data.data.body+'</span>               <br/><div class="info"><p> <div id="funform"> <div>'+data.data.created_at+'</div><a  class="fa fa-trash post_delete" data-id="'+data.data.id+'" data-url="/deletepost/'+data.data.id+'"></a><a class="fa fa-thumbs-up post_like"></a>   <a class="fa fa-comment post_comment"></a> <a class="fa fa-edit post_edit" </a></a>  </div> </p>  </div></p></li>');
      
      $('.close').click();
      $( '.postform' ).each(function(){
        this.reset();
    });
    
    }
     }
   ,error:function(data)
   {
     $('#errors').show();
     $('#errors').html('');
       var errors=data.responseJSON;
       $.each(errors,function(v,k)
       
       {
        $('#errors').append(v+"<br/>");

       }
       );
   }
   
    })



    });

my view

<div class="container-fluid">
        <div class="page col-lg-12">
          
            <ul id="posts" class="row">
                 @foreach($posts as $post)
                    <li class="arrow_box col-md-10 col-lg-10 offset-lg-1">
                    <p><span class="username">{{$post->user->name}} </span> &nbsp<span id="title">{{$post->title}}</span>
                    
                    <br/>
               <span id="body">{{$post->body}}</span>
                                   <br/>
                    <div class="info">
                    <p> 
                   <div id="funform">
                    <div>{{$post->updated_at->format('d M Y - H:i:s')}}</div>
                  <a  class="fa fa-trash post_delete" data-token="{{ csrf_token() }}" data-id="{{$post->id}}" data-url="/deletepost/{{$post->id}}"></a>
                   <a class="fa fa-thumbs-up post_like"></a>
                   <a class="fa fa-comment post_comment"></a>
                   <a class="fa fa-edit post_edit" </a></a>
                   </div> 
                   </p>
                   </div>
                    
                    </p>
                    
                    </li>
                @endforeach
                
            </ul>
             <button class="btn mybtn right" data-toggle="modal" data-target="#exampleModalCenter">post</button>
 
            <!-- Button trigger modal -->

marioeid left a reply on How To Access The Username If I Have The Post Using Eloquent

thanks i am just looking stupid right now it worked :) thanks

marioeid started a new conversation How To Access The Username If I Have The Post Usin Eloquent

i am using post->user->name but it throws this error

Trying to get property 'name' of non-object (View: D:\courses\web\web_projects\nuts_of_C++\resources\views\blog.blade.php)

my view

@foreach($posts as $post)
                    <li class="arrow_box col-md-10 col-lg-10 offset-lg-1">
                    <p><span class="sl">{{$post->user->name}}</span><span id="title">{{$post->title}}</span>
                    
                    <br/>
               <span id="body">{{$post->body}}</span>
                                   <br/>
                    <div class="info">
                    <p> 
                   <div id="funform">
                    <div>{{$post->updated_at->format('d M Y - H:i:s')}}</div>
                  <a  class="fa fa-trash post_delete" data-token="{{ csrf_token() }}" data-id="{{$post->id}}" data-url="/deletepost/{{$post->id}}"></a>
                   <a class="fa fa-thumbs-up post_like"></a>
                   <a class="fa fa-comment post_comment"></a>
                   <a class="fa fa-edit post_edit" </a></a>
                   </div> 
                   </p>
                   </div>
                    
                    </p>
                    
                    </li>
                @endforeach
             ```
  my user table

marioeid left a reply on I Get Error 500 When Trying To Post A Long Post

the migration

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
           $table->increments('id');
           $table->string('body');
           $table->string('title');
           $table->integer('user_id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('posts');
    }
}

marioeid started a new conversation I Get Error 500 When Trying To Post A Long Post

it posts normally when the body is short and i don't know if there's a limit to how many (char) i could use or string size the route

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', '[email protected]');
Route::get('/blog', '[email protected]');
Auth::routes();
Route::get('/home', '[email protected]')->name('home');
Route::get('ajax', function(){ return view('ajax'); });
Route::post('/postajax','[email protected]');
Route::post('/createpost','[email protected]');
Route::delete('/deletepost/{id}',['uses'=>'[email protected]','as'=>'post.delete','middleware'=>'auth']);

the ajax

 $('#post_create').on('click', function(e){
    
    //  var url=$(this).attr('action');
    //  var post=$(this).attr('method');
    e.preventDefault();
    //  var body=$('#body').val();
    //  var tilte=$('#title').val();
    $.ajax({
        // headers: {
        //     'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        //   }
        //   ,        
    url:'/createpost',
    type:'POST',
    data:$(".postform").serialize(),
    dataType: 'JSON',
   success:function(data)
   {
     
      if(data.status == "success"){


      $('#posts').append('<li class="arrow_box col-md-10 col-lg-10 offset-lg-2"><p><span id="title">'+data.data.title+'</span><br/><span id="body">'+data.data.body+'</span>               <br/><div class="info"><p> <div id="funform"><a   <a  class="fa fa-trash post_delete" data-id="'+data.data.id+'" data-url="/deletepost/'+data.data.id+'"></a><a class="fa fa-thumbs-up post_like"></a>   <a class="fa fa-comment post_comment"></a> <a class="fa fa-edit post_edit" </a></a>  </div> </p>  </div></p></li>');
      
      $('.close').click();
      $( '.postform' ).each(function(){
        this.reset();
    });
    
    }
     }
   

the view

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="css/blog.css">
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=UnifrakturMaguntia">
    <link rel="stylesheet" href="/mathscribe/jqmath-0.4.3.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css?family=Prociono" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Playfair+Display" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Dancing+Script" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Anton|Bitter|Noto+Serif|Roboto+Slab" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Abril+Fatface|Courgette|Crimson+Text|Great+Vibes|Kaushan+Script|Merienda|Old+Standard+TT|Pacifico|Satisfy" rel="stylesheet">
  

    <title>BLOG</title>
</head>

<body>
    <div class="interface">
        <img class="sz" src="img/iphone_ipad_apple_watches_stylus_pen_style_99204_2560x1080.jpg">
        <div class="centered">C++ Blog</div>
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-12 text-center centered2">
            <i class="fa fa-google-plus cir"></i>
            <i class="fa fa-facebook cir"></i>
            <i class="fa fa-twitter cir"></i>
           
        </div>
    </div>
    
    <div class="container-fluid">
        <div class="page col-lg-12">
          
            <ul id="posts" class="row">
                 @foreach($posts as $post)
                
                    <li class="arrow_box col-md-10 col-lg-10 offset-lg-2">
                    <p><span id="title">{{$post->title}}</span>
                    
                    <br/>
               <span id="body">{{$post->body}}</span>
                                   <br/>
                    <div class="info">
                    <p> 
                   <div id="funform">
                    
                  <a  class="fa fa-trash post_delete" data-token="{{ csrf_token() }}" data-id="{{$post->id}}" data-url="/deletepost/{{$post->id}}"></a>
                   <a class="fa fa-thumbs-up post_like"></a>
                   <a class="fa fa-comment post_comment"></a>
                   <a class="fa fa-edit post_edit" </a></a>
                   </div> 
                   </p>
                   </div>
                    
                    </p>
                    
                    </li>
                @endforeach
                
            </ul>
             <button class="btn mybtn right" data-toggle="modal" data-target="#exampleModalCenter">post</button>
 
            <!-- Button trigger modal -->

<!-- Modal -->
      <form class="postform">
        {{ csrf_field() }}
        <div class="modal fade" id="exampleModalCenter" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
          <textarea id="formtitle" class="title" placeholder="Add your title" name="title"></textarea>
           
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
              
            <div class="form-group">           
             <textarea  id="formbody" name="body"  class="bl" placeholder="Add your body"></textarea>
            </t>
            </div>
            <button   id="post_create" class="btn mybtn right">post</button>
 
      </div>
    </div>
  </div>





  </form>
  </div>

        </div>
      <div id="errors"></div>
      

    </div>




    <script src="/mathscribe/jquery-1.4.3.min.js"></script>
    <script src="/mathscribe/jqmath-etc-0.4.6.min.js" charset="utf-8"></script>


    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-1.11.1.js" integrity="sha256-MCmDSoIMecFUw3f1LicZ/D/yonYAoHrgiep/3pCH9rw=" crossorigin="anonymous">
    </script>
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js" integrity="sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk=" crossorigin="anonymous"></script>

      <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

       <script src="js/BLOG.js">


    </script>




</body>



</html>
13 Dec
3 months ago

marioeid left a reply on Error 419 But I Am Passing The Token

still the same error

marioeid started a new conversation Error 419 But I Am Passing The Token

when i click delete it gives me error 419 still don't know why but it doesn't work my routes


Route::get('/', '[email protected]');
Route::get('/blog', '[email protected]');
Auth::routes();
Route::get('/home', '[email protected]')->name('home');
Route::get('ajax', function(){ return view('ajax'); });
Route::post('/postajax','[email protected]');
Route::post('/createpost','[email protected]');
Route::delete('/deletepost/{id}',['uses'=>'[email protected]','as'=>'post.delete','middleware'=>'auth']);

my view

  <ul id="posts" class="row">
                 @foreach($posts as $post)
                
                    <li class="arrow_box col-md-10 col-lg-10 offset-lg-2">
                    <p><span id="title">{{$post->title}}</span>
                    
                    <br/>
               <span id="body">{{$post->body}}</span>
                                   <br/>
                    <div class="info">
                    <p> 
                   <div id="funform">
                   <meta name="csrf-token" content="{{ csrf_token() }}">

                  <a  class="fa fa-trash post_delete" data-id="{{$post->id}}" data-url="/deletepost/{{$post->id}}"></a>
                   <a class="fa fa-thumbs-up post_like"></a>
                   <a class="fa fa-comment post_comment"></a>
                   <a class="fa fa-edit post_edit" </a></a>
                   </div> 
                   </p>
                   </div>
                    
                    </p>
                    
                    </li>
                @endforeach
                
            </ul>

my ajax note: there's only one class called post_delete in my view

 $('.post_delete').on('click',function(e)
    {
        e.preventDefault();
         var id = $(this).data("id");
         var url=$(this).data("url");
         var th=$(this).parent().parent().parent();    
        $.ajax({
            url:url,
            type: 'DELETE',
            data: {  "_token": "{{ csrf_token() }}"},
            dataType: 'JSON',
            success:function(data)
            {
               th.remove();
            },
        });
    }
08 Dec
3 months ago

marioeid started a new conversation Ajax Laravel

i did this but now how after i retraive data i send it to the data base and show it in the same page witout updating success is working after i retraive data now i don't save it and if i show the data using jquery what if i posted two times will it work and is this the right way to show data on my view my js

$(document).on("ready", function () {
    // start up hidden
    $('#errors').hide();
    $('.interface').hide();
    $('.centered').hide();
    $('.centered2').hide();
    $('.page').hide();
    // show the page
    $('.interface').slideDown(2000);
    $('.centered').slideDown(3000);
    $('.centered2').slideDown(3000);
    $('.page').slideDown(3000);
    $('#post_create').on('click', function(e){
     e.preventDefault();
     var url=$(this).attr('action');
     var post=$(this).attr('method');
     var data=$(this).serialize();
    $.ajax({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
          ,        
    type:post,
    url:url,
    data:data,
    contenttyp:"form/data",
    processData:false,
   success:function(data)
     {
      alert('hello');
     }
   ,error:function(data)
   {
     $('#errors').show();
     $('#errors').html('');
       var errors=data.responseJSON;
       $.each(errors,function(v,k)
       
       {
        $('#errors').append(v+"<br/>");

       }
       );
   }
   
    })



    });
});

my controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\post;
class Postcontroller extends Controller
{
    //
    public function store(Request $request)
    {
      $this->validate($request,['body'=>'required|max:1000','title'=>'required|max:1000']);
        $post=new Post;
        $post->body=request('body');
        $post->title=request('title');
        $request->user()->posts()->save($post);
       return $post;
    }
    public function destroy($id)
    {
      $post=Post::find($id)->first();
      $post->delete();
      return redirect('/blog');
    }
}

07 Dec
3 months ago

marioeid left a reply on How To Use Ajax In Laravel ?

@cronix i did this but now how after i retraive data i send it to the data base and show it in the same page witout updating success is working after i retraive data now i don't save it and if i show the data using jquery what if i posted two times will it work and is this the right way to show data my js

$(document).on("ready", function () {
    // start up hidden
    $('#errors').hide();
    $('.interface').hide();
    $('.centered').hide();
    $('.centered2').hide();
    $('.page').hide();
    // show the page
    $('.interface').slideDown(2000);
    $('.centered').slideDown(3000);
    $('.centered2').slideDown(3000);
    $('.page').slideDown(3000);
    $('#post_create').on('click', function(e){
     e.preventDefault();
     var url=$(this).attr('action');
     var post=$(this).attr('method');
     var data=$(this).serialize();
    $.ajax({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
          ,        
    type:post,
    url:url,
    data:data,
    contenttyp:"form/data",
    processData:false,
   success:function(data)
     {
      alert('hello');
     }
   ,error:function(data)
   {
     $('#errors').show();
     $('#errors').html('');
       var errors=data.responseJSON;
       $.each(errors,function(v,k)
       
       {
        $('#errors').append(v+"<br/>");

       }
       );
   }
   
    })



    });
});

my controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\post;
class Postcontroller extends Controller
{
    //
    public function store(Request $request)
    {
      $this->validate($request,['body'=>'required|max:1000','title'=>'required|max:1000']);
        $post=new Post;
        $post->body=request('body');
        $post->title=request('title');
        $request->user()->posts()->save($post);
       return $post;
    }
    public function destroy($id)
    {
      $post=Post::find($id)->first();
      $post->delete();
      return redirect('/blog');
    }
}

marioeid started a new conversation How To Use Ajax In Laravel ?

i am new to laravel i have kind of small blog post project i want to show the posts witout reloading i tried a simple method but still don't know how to do it and show the posts witout reloading the page i am using jquery routes

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', '[email protected]');
Route::get('/blog', '[email protected]');
Auth::routes();
Route::get('/home', '[email protected]')->name('home');
Route::post('/createpost','[email protected]');
Route::get('/deletepost/{id}',['uses'=>'[email protected]','as'=>'post.delete','middleware'=>'auth']);

post controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\post;
class Postcontroller extends Controller
{
    //
    public function store(Request $request)
    {
      $this->validate($request,['body'=>'required|max:1000','title'=>'required|max:1000']);
        $post=new Post;
        $post->body=request('body');
        $post->title=request('title');
        $request->user()->posts()->save($post);
       return redirect('/blog');
    }
    public function destroy($id)
    {
      $post=Post::find($id)->first();
      $post->delete();
      return redirect('/blog');
    }
}

my blog view

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="css/blog.css">
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=UnifrakturMaguntia">
    <link rel="stylesheet" href="/mathscribe/jqmath-0.4.3.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css?family=Prociono" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Playfair+Display" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Dancing+Script" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Anton|Bitter|Noto+Serif|Roboto+Slab" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Abril+Fatface|Courgette|Crimson+Text|Great+Vibes|Kaushan+Script|Merienda|Old+Standard+TT|Pacifico|Satisfy" rel="stylesheet">


    <title>BLOG</title>
</head>

<body>
    <div class="interface">
        <img class="sz" src="img/iphone_ipad_apple_watches_stylus_pen_style_99204_2560x1080.jpg">
        <div class="centered">C++ Blog</div>
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-12 text-center centered2">
            <i class="fa fa-google-plus cir"></i>
            <i class="fa fa-facebook cir"></i>
            <i class="fa fa-twitter cir"></i>
           
        </div>
    </div>

    <div class="container-fluid">
        <div class="page col-lg-10 offset-lg-1">
          
            <ul>
                 @foreach($posts as $post)
                
                    <li>
                    <p><span id="title">{{$post->title}}</span>
                    
                    <br/>
               <span id="body">{{$post->body}}</span>
                                   <br/>
                    <div class="row info">
                    <p> <a href="#">like</a> 
                     <a href="#">comment</a>
                     <a href={{route('post.delete',['id'=>$post->id])}}>delete</a>
                    </p></div>
                    <hr>
                 
                    </p>
                    
                    </li>
                
                @endforeach
                
            </ul>
             <button class="btn mybtn right" data-toggle="modal" data-target="#exampleModalCenter">post</button>
 
            <!-- Button trigger modal -->

<!-- Modal -->
      <form class="postform" method="POST" action="/createpost" >
      {{csrf_field()}}
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
          <textarea class="title" placeholder="Add your title" name="title"></textarea>
           
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
              
            <div class="form-group">           
             <textarea  name="body"  class="bl" placeholder="Add your body"></textarea>
            </t>
            </div>
            <button   id="post_create" type="submit" class="btn mybtn right">post</button>
 
          
            <hr>

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





  </form>
  </div>

        </div>

    </div>




    <script src="/mathscribe/jquery-1.4.3.min.js"></script>
    <script src="/mathscribe/jqmath-etc-0.4.6.min.js" charset="utf-8"></script>


    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-1.11.1.js" integrity="sha256-MCmDSoIMecFUw3f1LicZ/D/yonYAoHrgiep/3pCH9rw=" crossorigin="anonymous">
    </script>
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js" integrity="sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk=" crossorigin="anonymous"></script>
       <script src="js/BLOG.js">


    </script>




</body>



</html>

what i am trying to achieve in ajax but i don't think that's the right way and still don't know how to do it

$(document).on("ready", function () {
    // start up hidden
    $('.interface').hide();
    $('.centered').hide();
    $('.centered2').hide();
    $('.page').hide();
    // show the page
    $('.interface').slideDown(2000);
    $('.centered').slideDown(3000);
    $('.centered2').slideDown(3000);
    $('.page').slideDown(3000);
    $('#post_create').on('click', function(e){
     e.preventDefault();
    $.ajax({
    method:'POST',
    url:'/createpost',
    data:{body:$('#body').val(),title:$('#tilte').val(),_token: CSRF_TOKEN},
   succsess:function(data)
   {
      alert('hello');
   }
   
    })



    });
});
02 Dec
3 months ago

marioeid left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Insert Into `users` (`email`, `password`, `user_name`, `updated_at`, `created_at`) Values (a, A, A, 2018-12-01 00:04:08, 2018-12-01 00:04:08))

thanks for every one who tried to help i opened database.php file and i hardcoded it when i and then removed the hardcoded with forged and then it worked and i still don't know why but it worked

30 Nov
3 months ago

marioeid left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Insert Into `users` (`email`, `password`, `user_name`, `updated_at`, `created_at`) Values (a, A, A, 2018-12-01 00:04:08, 2018-12-01 00:04:08))

my database is in php my admin and it only contains the user table with it's columns and it's all clear i run your command and it returned this


  [
     "driver" => "mysql",
     "host" => "127.0.0.1",
     "port" => "3306",
     "database" => "nuts_of_c++",
     "username" => "root",
     "password" => "",
     "unix_socket" => "",
     "charset" => "utf8mb4",
     "collation" => "utf8mb4_unicode_ci",
     "prefix" => "",
     "strict" => true,
     "engine" => null,
   ]

marioeid left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Insert Into `users` (`email`, `password`, `user_name`, `updated_at`, `created_at`) Values (a, A, A, 2018-12-01 00:04:08, 2018-12-01 00:04:08))

and that's my config.inc file


<?php
/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';

/*
 * End of servers configuration
 */

?>

marioeid left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Insert Into `users` (`email`, `password`, `user_name`, `updated_at`, `created_at`) Values (a, A, A, 2018-12-01 00:04:08, 2018-12-01 00:04:08))


APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:onPzKEjS9QArHj2SU5b/kWr9y2Do3usdJo2dnMa8+yw=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=nuts_of_c++
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

that's my env file and that's my current localhost through php artisan serve command http://127.0.0.1:8000

marioeid started a new conversation SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Insert Into `users` (`email`, `password`, `user_name`, `updated_at`, `created_at`) Values (a, A, A, 2018-12-01 00:04:08, 2018-12-01 00:04:08))

i read about the error in stack over flow and in laravel discussions but still that didn't fix it my user table

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->string('user_name');
            $table->string('email');
            $table->string('password');
            
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

my view


      <form method="POST" action="/signup">
                 {{ csrf_field() }}
        <div class="form-group">
            <label>user name</label>
            <input type="text" class="form-control" name="user_name" placeholder="username">
        </div>
       
        <div class="form-group">
            <label class="me">Email address</label>
            <input type="text" class="form-control" aria-describedby="emailHelp" placeholder="Enter email" name="email">
            <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
        </div>
        <div class="form-group">
            <label>Password</label>
            <input type="text" name="password" class="form-control" placeholder="Password">
        </div>
        <div class="form-check">
            <input type="checkbox" class="form-check-input" id="exampleCheck1">
            <label class="form-check-label">Check me out</label>
        </div>
        
        <button type="submit" class="btn btn-primary">Submit</button>
    </form>

my user controller


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\user;
class usercontroller extends Controller
{
    //
    public function signup(Request $request)
    {
        $user=new user;
      $user->email=request('email');
      $user->password=request('password');
      $user->user_name=request('user_name');
      $user->save();
      return redirect('/');
    }
    public function singin(Request $request)
    {

    }
}

my routes

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', '[email protected]');
Route::get('/blog', '[email protected]');
Route::post('/signup','[email protected]');
21 Nov
4 months ago

marioeid started a new conversation Can I Use Algorithms In Laravel Or In Database Or In Web Development In General

i learned laravel basics and i love it it's simple and amazing but still very beginner in web development in general so i want to know that what if i want apply algorithms in backend for specific task laravel or database or using elquonet example (using binary search on sorted data for example how can i do it and can i do it in the database or does the database already uses binary search and that kind if algorithms ) my question in general if i could use the algorithms in backend and in web in general