david001

Experience

8,400

1 Best Reply Awards

  • Member Since 2 Years Ago
  • 2 Lessons Completed
  • 5 Favorites

11th December, 2017

david001 started a new conversation How Map Of Country Is Made With Js • 1 day ago

I want to make a map and show some results.is there any api for this . i want to make this map https://election.ekantipur.com/ and show results when user hover on map. i search same map on highcharts.com but could not found. please share your idea about creating map .

10th December, 2017

david001 left a reply on Remove Unwanted Text From Database • 2 days ago

do {!! display here !! }

8th December, 2017

david001 left a reply on How To Query This • 3 days ago

doing this i got only name of district with zero crime ,although i have some crime in every district

 $districts = District::with([
    'cases' => function ($query) {
            $query->whereMonth('crime_date', date('m')) 
                    ->whereYear('crime_date', date('y'));
        },
    'cases.crime'
])->get();

i got this in controller writing above code

[
{
id: 1,
name: "A",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00",
cases: [ ]
},
{
id: 2,
name: "B",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00",
cases: [ ]
}
]

But writing this

 $districts =  District::with('cases.crime')->get();
return $districts;

i got this

[
{
id: 1,
name: "A",//name of district
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00",
cases: [   //registered cases
    {
    id: 1,
    crime_id: 1,
    district_id: 1,
    crime_date: "2017-12-31 00:00:00",
    created_at: "-0001-11-30 00:00:00",
    updated_at: "-0001-11-30 00:00:00",
crime: {//name of crime from crimes table
id: 1,
name: "Rape",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00"
}
},
{
id: 3,
crime_id: 4,
district_id: 1,
crime_date: "2017-12-31 00:00:00",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00",
crime: {
id: 4,
name: "Women trafficking",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00"
}
},
{
id: 4,
crime_id: 3,
district_id: 1,
crime_date: "2017-12-31 00:00:00",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00",
crime: {
id: 3,
name: "Murder",
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00"
}
}
]
},
{
id: 2,
name: "B",//name of district from districts table
created_at: "-0001-11-30 00:00:00",
updated_at: "-0001-11-30 00:00:00",
    cases: [   
    {
    id: 2,
    crime_id: 1,
    district_id: 2,
    crime_date: "2017-12-31 00:00:00",
    created_at: "-0001-11-30 00:00:00",
    updated_at:  "-0001-11-30 00:00:00",
    crime: {
    id: 1,
    name: "Rape",
    created_at: "-0001-11-30 00:00:00",
    updated_at: "-0001-11-30 00:00:00"
}
}
]
}
]

I want to show total crime and name of crime on particular district at the end of month For eg:->total crime in "A" district was 3 and name of crime are rape,murder,traficking on month december ->total crime in "B" district was 1 and name of crime are "rape" on month december //etc for 12 month in each district

Simillarly total crime in "A" district was 4 and name of crime are rape,murder,traficking,violence on month january

david001 left a reply on How To Query This • 4 days ago

@tykus I have updated according to yours but i got error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'crime_date' in 'where clause' (SQL: select * from `crimes` where `crimes`.`id` in (1, 2, 3, 4) and month(`crime_date`) = 12 and year(`crime_date`) = 17)```


its looking ```crime_date ```in ```crimes``` table, i  have ```crime_date``` in ```cases``` table

david001 started a new conversation How To Query This • 4 days ago

I am working in a project.for now lets say i have 3 tables "districts", "crimes" , "cases". Cases table holds all the registered cases.

Case.php

class Case extends Model
{
        protected $table = 'cases';
        protected $fillable=['person_name','crime_id ,'district_id','crime_date'];

}

District.php

class District extends Model
{
        protected $table = 'districts';
        protected $fillable=['name'];//name of districts like "A district","B district" etc


}

Crime.php

class Crime extends Model
{
        protected $table = 'crimes';
        protected $fillable=['name'];//name of different types of crime like rape,murder etc

}

My output at the end of month should look like below in report.blade.php

  District name   |total crime    | crime
   A                                  3                   rape
                                                            murder
                                                attempt to murder

   B                                  1                    rape

  C                                    0                    No crime reported 

ReportController.php

public function index(){
     
        //get above format result here
    return view('case.report');
}

I think group by district_id can give number of crime in that district Id I need to fetch district with total crimes reported and types of crime for a month Please help me

4th December, 2017

david001 started a new conversation Filter Products With Checkbox • 1 week ago

I have seen many e commerce site in which user can filter products by clicking checkbox. for example:let say there are different brand of mobile: like samsung,nokia,aCompany,bCompany,cCompany etc. Different colour ,size,memory.

when user check samsung checkbox pages display only samsumg mobile,when user further check 8Gb memeory checkbox ,page display samsung mobile with 8Gb memory and so on.

i want to implement such feature with jquery/Ajax and Laravel. Can you give me idea how this is done

29th November, 2017

david001 left a reply on Passing Coordinates From View To Controller • 1 week ago

how to check whether i am getting latitude or longitude or not in controller. suppose i want to display latitude(dd() ) send from post request from view

david001 started a new conversation Passing Coordinates From View To Controller • 1 week ago

I am getting latitude and longitude in view , but these are not passed in controller.Please help me to fix this issue.

js

<script>

        $(document).ready(function(){
            get_location();
        });

        function get_location()
        {
            if(navigator.geolocation)
            {
                navigator.geolocation.getCurrentPosition(function(position){

                        var latitude = position.coords.latitude;
                        var longitude = position.coords.longitude;



                        $.post('http://localhost/api/coordinates', 'latitude='+latitude+'&longitude='+longitude);

                });
            }
        }
</script>

Route: api.php


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

controller:

public function getCoordinates(Request $request)
    {
      //  return"ok";

        $lat=$request->latitude;
        $lng=$request->longitude;
        return $lat;
    }

    public function showCoordinates(Request $request)
    {
        echo $this->getCoordinates($request);
    }

when i am in browser at localhost:8000/api/test i got blank page no any latitude

28th November, 2017

david001 left a reply on Delete File Dropzone+laravel • 1 week ago

yes it is not permanent solution

david001 started a new conversation Delete File Dropzone+laravel • 2 weeks ago

How to delete particular file form dropzone and database This is my upload function:

 public function postUpload(Request $request,$id)
    {
         
        $destinationPath = 'images'; 
        $fileName=  $request->file('file')->getClientOriginalName(); 
        
        $upload_success = $request->file('file')->move($destinationPath, $fileName); 
     if($upload_success){
      
            $image = new Image;
            $image->filename = $fileName ;
           
            $image->save();

      }

 }

This is my view js :

<script>
Dropzone.options.myAwesomeDropzone = {
            maxFilesize: 2, // Size in MB
            addRemoveLinks: true,
            removedfile: function(file) { 

            var name = file.name;   
            console.log(file.name);       
            $.ajax({
              headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
         },
            type: 'POST',
            url: '/delete',
            data: {filename:name},
            dataType: 'html'
        });
            var fileRef;
                return (fileRef = file.previewElement) != null ? 
                      fileRef.parentNode.removeChild(file.previewElement) : void 0;
            },


                success: function(file, response) {
                  alert(response);
                 
                },

                error: function(file, response) {
                      alert(response);
                      return false;
                }
        };



</script>

This works perfectly . when i click remove link in dropzone after uploading file it deletes image from database ,But my problem is if two images are of same name in db then one click deletes both image,which i don't want

obviously i can do like this $fileName= $request->file('file')->getClientOriginalName(); $newFileName=$fileName.time();

so filename may be unique in db. but i need to delete file as well and through dropzone i get orginal file name

This is my delete method:

public function delete(Request $request){    
    $filename =  $request->get('filename');//gives orginal file name eg:abc.jpg
    Image::where('filename',$filename)->delete();
    return "ok";
   }

david001 left a reply on Dropzone Js:response After Upload Success • 2 weeks ago

This script solve my problem

Dropzone.options.myAwesomeDropzone = { maxFilesize: 2, // Size in MB addRemoveLinks: true, removedfile: function(file) {
                 // var name = file.name;        

// $.ajax({ // type: 'POST', // url: 'delete.php', // data: "id="+name, // dataType: 'html' // });

          var fileRef;
          return (fileRef = file.previewElement) != null ? 
                  fileRef.parentNode.removeChild(file.previewElement) : void 0;
        },

success: function(file, response) {
              //alert(response);
              $('#display_images').html(response);
            },

error: function(file, response) {
                  alert(response);
       }

};

27th November, 2017

david001 started a new conversation Dropzone Js:response After Upload Success • 2 weeks ago

How can i get response after successful upload by dropzone js and Laravel

my upload code at view is:

create.blade.php

<form action="{{url('gallery/post')}}/{{$post->id}}" class="dropzone">
    {{ csrf_field() }}
  
</form>

Route:

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

controller:

public function upload($id)
    {
      
            $post = Post::find($id);
            return view('gallery.create',compact('post'));
      
    } 

    public function postUpload(Request $request,$id)
    {
         
        $destinationPath = 'images'; 
        $extension =  $request->file('file')->getClientOriginalExtension(); 
        $fileName = time() . '.' . $extension;
        $upload_success = $request->file('file')->move($destinationPath, $fileName); 

      
            $image = new Image;
            $image->filename = $fileName ;
            $image->post_id = $id;
            $image->save();
      }

    ```    



26th November, 2017

david001 left a reply on How To Solve It • 2 weeks ago

@SyedAbuthahir it won't work since i am in gallery/create page (according to yours) where is my upload form and i need to fetch all images in same page (gallery/create) below form.

25th November, 2017

david001 started a new conversation How To Solve It • 2 weeks ago

I need to fetch all images based on current url id :eg:localhost:8000/company/post/id using jquery.

public function upload($id)
    {
        $post= \App\Post::find($id);

        return view('gallery.create',compact('post'));
        
    }

  public function postUpload(Request $request,$id)
   {   
        $destinationPath = 'gallery'; 
        $extension =  $request->file('file')->getClientOriginalExtension(); 
        $fileName = time() . '.' . $extension;
        $upload_success = $request->file('file')->move($destinationPath, $fileName); 
            
            $image = new Image;
            $image->filename = $fileName ;
            $image->post_id = $id;
            $image->save();
    }

Route:

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

view:


<form action="{{url('image/post')}}/{{$post->id}}" enctype="multipart/form-data">
    {{ csrf_field() }}
  //.......
</form>



<div id="show">display all images here based on current post id in url</div>

//Note: i have upload form above and display div below on same page


<script type="text/javascript">

$(document).ready( function(){
$('#show').load('url that pull all images based on current upload id');
refresh();
});
 
function refresh()
{
    setTimeout( function() {
$('#show').fadeOut('slow').load('/url that pull all images based on current upload id').fadeIn('slow');
      refresh();
    }, 2000);
}
</script>

for example :my current upload id in browser is localhost::8000/company/post/id Based on this Id i need to fetch all images in show div using jquery above.

I think i need to make another method that returns all images based on current Post Id.But how to get current Id. in another method so that i call pull images based on that Id

david001 left a reply on How To Get Id From One Function To Next Function • 2 weeks ago

error: Missing argument 1 for App\Http\Controllers\PostController::getImagesOfLatestPost()

david001 left a reply on How To Get Id From One Function To Next Function • 2 weeks ago

I am not getting error but its not working

david001 left a reply on How To Get Id From One Function To Next Function • 2 weeks ago

i am getting error

Type error: Argument 1 passed to App\Http\Controllers\PostController::postUpload() must be an instance of Illuminate\Http\Request, none given, called in ...

david001 left a reply on How To Get Id From One Function To Next Function • 2 weeks ago

please make it clear

david001 started a new conversation How To Get Id From One Function To Next Function • 2 weeks ago

I need id of one function to next function .how can i do this please help me Here after successfully saving data to database i want to grab that post Id in next function.


    public function postUpload(Request $request,$id)
    {
        $input =  $request->all();
        $postId = $id;

 
        $destinationPath = 'gallery'; 
        $extension =  $request->file('file')->getClientOriginalExtension(); 
        $fileName = time() . '.' . $extension;
        $upload_success = $request->file('file')->move($destinationPath, $fileName); 

        if($upload_success){
            
            $user = Auth::user();
            $image = new Image;
            $image->filename = $fileName ;
            $image->post_id = $postId ;
         
            $user->images()->save($image);
          
           }

         return $postId; //i need this id for second function

    }

Second method


    public function getImagesOfLatestPost()//this is get Route
    {
        return $this->postUpload($id);//first function
  
    }

I am not gettingpostId, i want post id because i want to load latest images based on post id from database with jquery.

24th November, 2017

david001 started a new conversation How To Route And Data • 2 weeks ago

I want to display my posts as : http://localhost:8000/posts/creatorName/postSlug my route is:

Route::get('posts/{creator}/{slug}', '[email protected]');

Controller:

public function show($slug){
    $posts = Post::where('slug',$slug)->first();

}

view:

@foreach($posts as $post)
    //display post title and description here
@endforeach 
link
    <center>
                <a href="/posts/{{ $post->user->name }}/{{$post->slug  }}" class="btn btn-primary">Read More</a></center>

In model i have used relationship: a user can have many posts and all posts belongs to user

23rd November, 2017

david001 left a reply on Ajax Request Laravel 5.5 • 2 weeks ago

remove datatType : 'json', or make it as datatType : 'text',

david001 left a reply on Ajax Post Error • 2 weeks ago

chrome browser

david001 left a reply on Ajax Post Error • 2 weeks ago

At network i got:

Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0

david001 left a reply on Ajax Post Error • 2 weeks ago

i got nothing ,i should be description but i didn't got,my route is correct

david001 left a reply on Ajax Post Error • 2 weeks ago

on dd($request->description) i got success from alert .but when i remove dd($request->description) i got same error. it may be because of image

david001 left a reply on Ajax Post Error • 2 weeks ago

i need help

22nd November, 2017

david001 started a new conversation Ajax Post Error • 2 weeks ago

I am getting error on saving data with Ajax,but without ajax it works.

and at network it says : 500 (Internal Server Error)

{,…}
exception
:
"Illuminate\Database\QueryException"
file
:
"C:\xampp\htdocs\WAN\vendor\laravel\framework\src\Illuminate\Database\Connection.php"
line
:
664
message
:
"SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'description' cannot be null (SQL: insert into `events` (`title`, `description`, `start_date`, `end_date`, `address`, `feature_image`, `user_id`, `slug`, `updated_at`, `created_at`) values (maha shiva ratri, , nnnnnnnnnnnnnnn, nnnnnnnnnnnnnn, kathmandu, public/files/z4w39pf94ynWB1OMqaNTQktC90aIAtGmkXciiclq.jpeg, 1, maha-shiva-ratri, 2017-11-22 17:11:41, 2017-11-22 17:11:41))"
trace
:
[{file: "C:\xampp\htdocs\WAN\vendor\laravel\framework\src\Illuminate\Database\Connection.php",…},…]
0
:
{file: "C:\xampp\htdocs\WAN\vendor\laravel\framework\src\Illuminate\Database\Connection.php",…}
1
:
{file: "C:\xampp\htdocs\WAN\vendor\laravel\framework\src\Illuminat
Some basic Git commands are:

controller:

public function store(Request $request)
    {
        if($request->file('feature_image')){
            $uploadedFile = $request->file('feature_image');        
            $path = $uploadedFile->store('public/files');
        }else{
            $path = 'default.png';
        }
        $event = new Event;
        $event->title = $request->title; 
        $event->description = $request->description; 
     
        $event->feature_image = $path;
        $event->user_id = \Auth::user()->id;
        $event->slug = str_slug($request->title);
        $event->tags()->sync($request->tag);
        $event->save();
        return "ok";


    }

view:

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <form action="#" method="POST" enctype="multipart/form-data">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading"></div>

                <div class="panel-body">
                <div class="form-group">
                    <label>Title :</label>
                    <input type="text" name="title" class="form-control" id="title" >
                </div>
                 <div class="form-group">
                    <label>Describe :</label>
                    <textarea name="description" id="description"></textarea>
                </div>
      
                    <div class="form-group">
                        <label>Feature Image:</label>
                  
                    <input type="file" id="feature_image" name="feature_image" class="form-control " >
                   </div>

                   <div class="form-group">
                       <label>Tag:</label>
                    <select class="form-control event-tag" name="tag[]" multiple="multiple" id="tag">
                        <option value="1">Alabama</option>

                        <option value="2">Wyoming</option>
                        <option value="3">ABC</option>
                        <option value="4">DEF</option>
                    </select>
                   </div>


              

                 <div class="form-group">
                   
                    <input type="" name="" id="btnClick" value="PUBLISH" class="btn btn-primary pull-right">
                </div>




               </div>
            </div>
        </div>
    </form>
    </div>
</div>
@endsection

       ```      
js:
$("#btnClick").click(function(e){ e.preventDefault(); var title = $("#title").val(); var description = $("#description").val();
var tag = $("#tag").val();


var form = new FormData();
var feature_image = $('#feature_image')[0].files[0];
form.append('feature_image', feature_image);
form.append('title', title);
form.append('description', description);
form.append('tag', tag);


var route = "events/store";


  $.ajax({
   
    url: route,
    cache: false,
    processData: false,
    contentType: false,
    headers: {
  'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                 },
    type: 'POST',
    
    data:form,

    beforeSend:function()
    {
      
    },
    
    success:function(data){
      console.log(data);
      alert('success');

    },
    error:function(msj){alert('Error!')}
        
   
});

});

``` route: ``` Route::post('/events/store', '[email protected]'); ``` please help me to fix this issue

20th November, 2017

david001 left a reply on Automatic Ajax Request • 3 weeks ago

i tried all steps mention above but i am not getting value in controller

18th November, 2017

david001 left a reply on Automatic Ajax Request • 3 weeks ago

var username = "changeable coordinate"; i just want to pass coordinate ie: var latitude = position.coords.latitude; to controller when user visit to my site

suppose i can get latitude and longitude in browser:console.log(position). i want to send it to controller so that based on user lat and lng i can recommend nearest things to user

david001 left a reply on Automatic Ajax Request • 3 weeks ago

i use trick like this but i won't work

 var url = window.location.href; //to get current url

       if(url = "http://localhost:8000/home"){  //if ```var url``` is equal to home url,fire ajax 
request

        var username = "john";
       
        $.ajax({
            type:"GET",
            cache:false,
            url:"/getValue",  

            data:{username:username},
        
 
          success: function(data) {
  
          }
        });
}

david001 started a new conversation Automatic Ajax Request • 3 weeks ago

Is there any tricks to send ajax data to controller without click event in view. I mean when user visit to the home page(url:'/home') i want to send some data to another url(ie: '/getValue')without clicking submit button.

My js in home.blade.php is

<script type="text/javascript">
       
        var username = "john";
       
        $.ajax({
            type:"GET",
            cache:false,
            url:"/getValue",  

            data:{username:username},
        
 
          success: function(data) {
  
          }
        });

</script>

my controller is

public function receiveData(Request $request)
{
    return $request->username;
       // i need to get here "john" 
}

Route


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

How can i get username 'John'to controller

david001 left a reply on Visitors Latitude And Longitude • 3 weeks ago

Since there is no any event , when visitor visit the website he/she do not click any button to send Ajax request . when they visit the home url, their coordinate should automatically go particular controller via ajax. How can i send this Js variable ie: var lat and var lng to controller when user land to home page please provide me some help.i have followed above all instructions but unable to solve.

david001 left a reply on Visitors Latitude And Longitude • 3 weeks ago

any help

17th November, 2017

david001 left a reply on Visitors Latitude And Longitude • 3 weeks ago

still not working :

my controller:

    public function geo()
    {
        return view('geo');

    }
    public function getCoordinate(Request $request)
    {
        return $request->latitude;
    }

view: geo.blade.php

<script>
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
        console.log(position);
        var lat = position.coords.latitude;
        var lng = position.coords.longitude;

        $.ajax({
            url:'http://localhost:8000/getgeo',
            type:'get',
            data:{latitude:lat,longitude:lng},

            
            success:function(data)
            {
                alert('success');
            }

        });
    });
}

</script>

Here i am getting latitude and longitude at console in geo.blade.php page .But now got in controller

Route:

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

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

david001 left a reply on Visitors Latitude And Longitude • 3 weeks ago

Thanks for help. But i have not got latitude at controller

home.blade.php js:

<script>
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
        console.log(position);
        var lat = position.coords.latitude;
        var lng = position.coords.longitude;

        $.ajax({
            url:'http://localhost:8000/getgeo',
            type:'get',
            data:{latitude:lat,longitude:lat},

            
            success:function(data)
            {
                alert('success');
            }

        });
    });
}

</script>

controller:

    public function getCoordinate(Request $request)
    {
        dd($request->latitude);
     

    }

david001 started a new conversation Visitors Latitude And Longitude • 3 weeks ago

I want to recommend the visitors the hotels near by him based on his current location. My problem is how to get not login user latitude and longitude so that i can recommend him nearby hotel.

i got some code here :

$circle_radius = 3959;
$max_distance = 20;
$lat = {how do i get visitor latitude here};
$lng = {how do i get visitor longitude here};

query would be like this

 return $candidates = DB::select(
               'SELECT * FROM
                    (SELECT id, name, address, phone, latitude, longitude, (' . $circle_radius . ' * acos(cos(radians(' . $lat . ')) * cos(radians(latitude)) *
                    cos(radians(longitude) - radians(' . $lng . ')) +
                    sin(radians(' . $lat . ')) * sin(radians(latitude))))
                    AS distance
                    FROM candidates) AS distances
                WHERE distance < ' . $max_distance . '
                ORDER BY distance
                OFFSET 0
                LIMIT 20;
            ');

9th September, 2017

david001 started a new conversation Google Map Api;How To Find Hospital • 3 months ago

Hello, I want to find the hospital around 3km from where currently i am living using Laravel and google map api. Does any one have working code or idea how to do this,please share

david001 left a reply on Update Total Count Laravel And Vue Js • 3 months ago

its working now, but is there better way to do using computed instead of waiting 1 sec for getting response

8th September, 2017

david001 left a reply on Update Total Count Laravel And Vue Js • 3 months ago

@KNietzsche i got updated count value but only after page refresh.should i need to use computed method

david001 left a reply on Update Total Count Laravel And Vue Js • 3 months ago

for example i got 2 for this url http://localhost:8000/events/participant/count/24

david001 left a reply on Update Total Count Laravel And Vue Js • 3 months ago

yes i passed eventId as Props

david001 left a reply on Update Total Count Laravel And Vue Js • 3 months ago

@PaulClarke its not working

david001 started a new conversation Update Total Count Laravel And Vue Js • 3 months ago

I want to display total participant for particular event without page refresh using vue, but i am not getting total participant: please help me to display total count for that particular event from database

controller:

public function countParticipant($id)
    {
         return Participant::where('event_id',$id)->count();
    }
//for eg: for event id 24 there are 2 participant
 event_id  user_id
  24            1
  24            5

view:

<template>
  <div>

  <p>count:{{ count }}</p>

  </div>

</template>

<script>

  export default {
   

    mounted(){
        
        this.count = this.countParticipant()

    },

     
    data(){
        return{

               count:''

        }
    },

    methods: {

    countParticipant()
    {
      axios.get('/events/participant/count/' + this.eventId)
        .then((response)=>{
        this.count = response.data
        //console.log(response.data);
        });
    }
  

    }
  
  }
</script>

21st August, 2017

david001 left a reply on Send Mail With Laravel And Mailtrap • 3 months ago

please help me

david001 started a new conversation No Method Is Configured To Handle The Form_params Config Key • 3 months ago

I am not able to send email using mailtrap. i got this error:No method is configured to handle the form_params config key

mail.php

<?php
return array(
    /*
    |--------------------------------------------------------------------------
    | Mail Driver
    |--------------------------------------------------------------------------
    |
    | Laravel supports both SMTP and PHP's "mail" function as drivers for the
    | sending of e-mail. You may specify which one you're using throughout
    | your application here. By default, Laravel is setup for SMTP mail.
    |
    | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
    |
    */
    'driver' => 'mandrill',
    /*
    |--------------------------------------------------------------------------
    | SMTP Host Address
    |--------------------------------------------------------------------------
    |
    | Here you may provide the host address of the SMTP server used by your
    | applications. A default option is provided that is compatible with
    | the Mailgun mail service which will provide reliable deliveries.
    |
    */
    'host' => 'smtp.mandrillapp.com',
    /*
    |--------------------------------------------------------------------------
    | SMTP Host Port
    |--------------------------------------------------------------------------
    |
    | This is the SMTP port used by your application to deliver e-mails to
    | users of the application. Like the host we have set this value to
    | stay compatible with the Mailgun e-mail application by default.
    |
    */
    'port' => 587,
    /*
    |--------------------------------------------------------------------------
    | Global "From" Address
    |--------------------------------------------------------------------------
    |
    | You may wish for all e-mails sent by your application to be sent from
    | the same address. Here, you may specify a name and address that is
    | used globally for all e-mails that are sent by your application.
    |
    */
    'from' => array('address' => 'from_email_address', 'name' => 'from_name'),
    /*
    |--------------------------------------------------------------------------
    | E-Mail Encryption Protocol
    |--------------------------------------------------------------------------
    |
    | Here you may specify the encryption protocol that should be used when
    | the application send e-mail messages. A sensible default using the
    | transport layer security protocol should provide great security.
    |
    */
    'encryption' => 'tls',
    /*
    |--------------------------------------------------------------------------
    | SMTP Server Username
    |--------------------------------------------------------------------------
    |
    | If your SMTP server requires a username for authentication, you should
    | set it here. This will get used to authenticate with your server on
    | connection. You may also set the "password" value below this one.
    |
    */
    'username' => 'mandrill_login_email',
    /*
    |--------------------------------------------------------------------------
    | SMTP Server Password
    |--------------------------------------------------------------------------
    |
    | Here you may set the password required by your SMTP server to send out
    | messages from your application. This will be given to the server on
    | connection so that the application will be able to send messages.
    |
    */
    'password' => 'mandrill_password',
    /*
    |--------------------------------------------------------------------------
    | Sendmail System Path
    |--------------------------------------------------------------------------
    |
    | When using the "sendmail" driver to send e-mails, we will need to know
    | the path to where Sendmail lives on this server. A default path has
    | been provided here, which will work well on most of your systems.
    |
    */
    'sendmail' => '/usr/sbin/sendmail -bs',
    /*
    |--------------------------------------------------------------------------
    | Mail "Pretend"
    |--------------------------------------------------------------------------
    |
    | When this option is enabled, e-mail will not actually be sent over the
    | web and will instead be written to your application's logs files so
    | you may inspect the message. This is great for local development.
    |
    */
    'pretend' => false,
);
Now set your api key in config/services.php


'mandrill' => [
    'secret' => 'your-mandrill-key',
],


config/services.php


'mandrill' => [ 'secret' => 'your-mandrill-key', ],


web.php
Route::get('/send',function(){

\Mail::send('welcome', [], function ($message){
    $message->to('ranjitkarki2@gmail.com')->subject('Expertphp.in - Testing mail');
});
    
});

in Composer i have "guzzlehttp/guzzle": "~4.0",

i have followed this website http://www.expertphp.in/article/how-to-integrate-mandrill-mail-server-in-laravel

19th August, 2017

david001 left a reply on How To Mark Checkbox State Based On Database Value • 3 months ago

@Snapey Thanks a lot,it worked now

david001 left a reply on How To Mark Checkbox State Based On Database Value • 3 months ago

@Snapey its showing one permission less, i mean role_id 1 has 10 permission_id, but in view i am getting only 9

similar for other role_id, one less

david001 left a reply on How To Mark Checkbox State Based On Database Value • 3 months ago

@cewlbird i got error

(2/2) ErrorException in_array() expects parameter 2 to be array, object given (View: C:\xampp\htdocs\blog\resources\views\manage\roles\edit.blade.php)

david001 left a reply on How To Mark Checkbox State Based On Database Value • 3 months ago

@Snapey i got error

(2/2) ErrorException Object of class App\Permission could not be converted to int (View: C:\xampp\htdocs\blog\resources\views\manage\roles\edit.blade.php)

david001 started a new conversation How To Mark Checkbox State Based On Database Value • 3 months ago

I am working in Roles and Permission.

I have fetched all permission from permissions table. I want to show all available permission to superadmin and at the same time if he has already that some permission then checkbox should be checked ,if some are not, checkbox should not checked for them

Permisson table has field: id,name,display_name,description,timestamp

roles table:id,name,display_name,description,timestamp

permission_user table:permission_id,user_id

Here is current state :http://imgur.com/a/bfveP

Rolecontroller:


public function edit($id)
    {
        $role = Role::where('id', $id)->with('permissions')->first();
        $permissions = Permission::all();

     //   dd($role);//i am getting permission of that role
        return view('manage.roles.edit')->with('permissions',$permissions)-   >with('role',$role);
    }

edit.blade.php


@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">

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

                <div class="panel-body">
               form...
                </div>
            </div>


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

                <div class="panel-body">
                @foreach($permissions as $permission)
                <p><input type="checkbox" name="" id="{{$role->display_name?'checked="checked"':''}}">
                {{$permission->display_name}}
                </p>
                @endforeach
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.