khaledSMQ

Experience

26,390

9 Best Reply Awards

  • Member Since 3 Years Ago
  • 323 Lessons Completed
  • 17 Favorites

30th June, 2017

khaledSMQ left a reply on Select2 Does Not Put All ID In The Query • 1 year ago

@Xanger i think this should be like


$articoli->id_gioco =  implode(',',  $request->get('id_gioco'));
$articoli->id_console = implode(',',  $request->get('id_console'));


31st May, 2017

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

@Heyaj05 Thanks for asking,

Since you are working in back-end to back-end calls there will be no problems or any security problems just make sure if you are in production exceptions are not exposed to public in case there is any error UnhandledException thrown

6th February, 2017

khaledSMQ left a reply on Serialize Callable Function • 1 year ago

i think you need to call closure after that cach

1st February, 2017

khaledSMQ left a reply on Route Group With Middleware And Parameters • 1 year ago

i can see this in my case

Route {#166 ▼
  +uri: "user/jobcards/acl"
  +methods: array:2 [▼
    0 => "GET"
    1 => "HEAD"
  ]
  +action: array:5 [▼
    "middleware" => array:2 [▼
      0 => "web"
      1 => "\Eventoh\Http\Middleware\AclMiddleware:$role:data:help"// here what we want
    ]

khaledSMQ left a reply on Route Group With Middleware And Parameters • 1 year ago

sorry for that i just forget computedMiddleware it's not available in L5.2

can you check dd($request->route())

khaledSMQ left a reply on Route Group With Middleware And Parameters • 1 year ago

you can use $request->route()->computedMiddleware to fetch the middleware's and parse the data or prams you want

khaledSMQ left a reply on Route Group With Middleware And Parameters • 1 year ago

Yes but not in group route method , sorry for that i missed it in first reply,

khaledSMQ left a reply on Route Group With Middleware And Parameters • 1 year ago

try this might help you



Route::group(["prefix" => "/user/jobcards", "middleware" => ['\App\Http\Middleware\AclMiddleware:role']], function () {

    Route::get('/acl', function () {

        return response('done');
    });

});


class AclMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next )
    {
         dd($request->route()->computedMiddleware);
        return $next($request);
    }
}

khaledSMQ left a reply on Check If Text Is Encrypted Before Running Encrypt::decrypt($text) • 1 year ago

okay, first of all by default Laravel uses AES-256-CBC and to determine if the data encrypted or not. It's depend on the string you are planing to encrypt, lets say if the string random ( no spaces, no english words ) means it's not possible to know, other wise you might think to use like space separator or try to find some words or use some helper functions like this

$plural = str_plural('child');
// from https://laravel.com/docs/5.4/helpers#paths

khaledSMQ left a reply on Show Response And Query Time • 1 year ago

try this

 DB::listen(function ($query) {
            // $query->sql
            // $query->bindings
            // $query->time
        });

khaledSMQ left a reply on Internal Server Error When Posting Ajax Call. • 1 year ago

can you dump your request

Route::POST('/changeDevNew', function(){
dd(Request()->all());
});

khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

can you do this please


<?php
// put this class in your  App\Http\Requests folder and make sure the namespace match your namespace
namespace App\Http\Requests;

use App\User;
use Illuminate\Foundation\Http\FormRequest;

class UserCreateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
           'username' => 'required|min:2',
            'email' => 'required|email',
            'password' => 'required',
        ];
    }
}


public function store(\App\Http\Requests\UserCreateRequest $request)
    {
         
        # Create
        $user = $this->create($request->all()))
        # Authenticate
        //auth()->login($user);

        # redirect
        return redirect()->home();
    }


protected function create(array $data)
    {
        return User::create([
            'name' => $data['username'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']), // always make sure not plain password in your database
        ]);
    }


khaledSMQ left a reply on Internal Server Error When Posting Ajax Call. • 1 year ago

have you setup your CSRF token

<meta name="csrf-token" content="{{ csrf_token() }}">
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
//or 

$.ajax({
 method: 'POST', 
 headers: {
        'X-CSRF-TOKEN': {{ csrf_token() }}
    }
.......

khaledSMQ left a reply on Laravel Should Fix Ability Add Related Tables Gets Created. • 1 year ago

have you setup you csrf

<meta name="csrf-token" content="{{ csrf_token() }}">

$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});

khaledSMQ left a reply on Check If Text Is Encrypted Before Running Encrypt::decrypt($text) • 1 year ago

what Encryption you are using

khaledSMQ left a reply on Dynamic Survey App • 1 year ago

or if the options is dynamic you need to create separate tables

like this

question table
Questions:
- id;
- survey_id;
- label;
- input_type;
- order;

options table
- question_id
- option (name or type or what ever)
- next_qustion_id

khaledSMQ left a reply on Dynamic Survey App • 1 year ago

what if you link it in the same table like this

Questions: |-> -id; | - survey_id; |-> - question_id; - label; - input_type; - options; - order;

khaledSMQ left a reply on Uploading A File To A Laravel POST Route Through My C# Desktop Application And I'm Getting CSRF Mismatch Errors • 1 year ago

if you don't like to do it throw API routes, here solution you maybe like to use it.

http://stackoverflow.com/a/31223247

khaledSMQ left a reply on Uploading A File To A Laravel POST Route Through My C# Desktop Application And I'm Getting CSRF Mismatch Errors • 1 year ago

I think you should not use web route for post form your C# application, instead you have to use API routes since it will not require CSRF but you need to got into authentication before posting depend on your requirements

https://laravel.com/docs/5.4/passport https://laravel.com/docs/5.4/passport#protecting-routes

khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

check the updated

khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

here is full code

   public function store(Request $request)
    {
         $v = Validator::make($request, [
             'username' => 'required|min:2',
            'email' => 'required|email',
            'password' => 'required',
        ]);

      if ($v->fails()) {
            return redirect('/registation form')
                        ->withErrors($v)
                        ->withInput();
        }

        # Create
        $user = User::create(request(['username', 'email', 'password']));

        # Authenticate
        //auth()->login($user);

        # redirect
        return redirect()->home();
    }


khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

yes you need to replace data with your request like this

$data = $request->only('username', ..... what ever data you want)

khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

why not using

php artisan make:auth

you will find great controllers out of the box for registration and login and forget password https://laravel.com/docs/5.4/authentication

khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

try

    $v = Validator::make($data, [
             'username' => 'required|min:2',
            'email' => 'required|email',
            'password' => 'required',
        ]);

    if ($v->fails()) {
            return redirect('your route here')
                        ->withErrors($validator)
                        ->withInput();
        }


``

khaledSMQ left a reply on Old Values Not Displaying • 1 year ago

have you tried to use Request validation class, and try to change it to ``` {!! old('email') !!}

khaledSMQ started a new conversation How To Cache Model In Redis • 1 year ago

Hi every one, I just recently started to work on caching and learn more about it, I would like to know if someone have experience for caching models and database queries especially update the cache after the data have been edited, Example , User model update the remember token changed every time you login, for this case i have to update my cached data, if you was in this kind if situation what is the best practice to follow and how to deal with cache data and update the memory for any changes.

27th January, 2017

khaledSMQ left a reply on Laravel Post Error • 1 year ago

have you checked form method

<form method="POST">

17th December, 2016

khaledSMQ left a reply on Laravel Echo Not Getting Broadcast Event • 1 year ago

Hi @laraadmin ,

it's a good idea to use laravel-echo-server if you care about authenticated private channels. if you are using Homestead for your development env, make sure to check the following steps

1- make sure supervisor is running in the background to keep tracking the queues. https://laravel.com/docs/5.3/queues#supervisor-configuration

2- in your handler Exception you need to add a piece of code for the broadcasting auth throwen exception.

if ($exception instanceof HttpException) {
    if ($exception->getCode() == 403) {

        return response([
                            'success' => false,
                            'code'    => $exception->getCode(),
                            'message' => $exception->getMessage()
                        ], 403);

    }

}

3- make sure you are not dumping any data in Handler.php ( laravel-echo-server will crash). 4- in your config/app.php you need to uncomment

 App\Providers\BroadcastServiceProvider

5- also don't forget in your .env what is the broadcast driver ( Redis ) 6- make sure to pass the arguments in your fired event

(
    broadcast (new App\Events\UserSignedUp($user->id)); // 
}

7- subscribe to "test-channel? then listen to ("UserSignedUp")

3rd December, 2016

khaledSMQ left a reply on How To Count User Logins? • 1 year ago

in laravel 5.3 you can override authenticated method in LoginController

 /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  mixed                    $user
     *
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {

         $user->loginCount++;
         $user->save();

    }

// this method will trigged once the user is authenticated
``

29th November, 2016

khaledSMQ left a reply on Trying To Get Property Of Non-object (View: • 1 year ago

@Jayanthkumar if you are sure there is data in customer table just verify your arg ID you are passing to where

28th November, 2016

khaledSMQ left a reply on Require Email If User Not Logged In But Not Require It If User Logged In • 1 year ago

simply you can do somthing like this

  $roles = [
        'name'          => 'required',
        'location'      => 'required',
        'contact_email' => 'required',
        'categories'    => 'required',
        'description'   => 'required'
    ];

    if (!Auth::check()) {
        $roles += [ 'email' => 'required|email|max:32|unique:users' ];
    }
 $this->validate($request, $roles);

khaledSMQ left a reply on Missing Argument 3 For App\Http\Controllers\ProjectCollaboratorsController::update() • 1 year ago

i think your route is wrong


public function update(Request $request, $projectId, $collaboratorId)
....


Route::put('projects/{projectId}/{collaboratorId}/permission',['uses'=>'[email protected]',]);

khaledSMQ left a reply on Laravel Session Check • 1 year ago

$value = $request->session()->pull('cart', 'default');

https://laravel.com/docs/5.3/session

khaledSMQ left a reply on Beanstalkd Job Handle Method Not Getting Executed • 1 year ago

did you run this command

php artisan queue:work --queue=high,default


``
also you can check this 

https://laravel.com/docs/5.3/queues#supervisor-configuration

khaledSMQ left a reply on Trying To Get Property Of Non-object (View: • 1 year ago

@JAYANTHKUMAR

simply the $row is null that's why you can do something like this

{{ old('email', @$row->email) }}
// by adding '@'  you will ignore email if it's null
``

23rd November, 2016

khaledSMQ left a reply on Homestead Box 0.6.0 Release (Including VMWare Provider) • 1 year ago

@SVPERNOVA09 i tried to update my homestead

vagrant box update "laravel/homestead"

getting this error

 ✝  ~  vagrant box update "laravel/homestead"
The machine with the name 'laravel/homestead' was not found configured for
this Vagrant environment.
 ✘ ✝  ~ 

can you please share how to update from 0.5.0 to 0.6.0

18th November, 2016

khaledSMQ left a reply on Ide-helper Doesn't Work, PHPStorm • 1 year ago

@ALEXP11223 did you register service provider?

// in your App/Providers/AppServiceProvider.php/
public function register()
{
    if ($this->app->environment() !== 'production') {
        $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
    }
 }

khaledSMQ left a reply on Reboot Ubuntu Server With PHP • 1 year ago

Try this

//http://www.linuxquestions.org/questions/linux-newbie-8/shutdown-and-reboot-linux-system-via-php-script-713379/#post3486126


<?php
$command = "cat $pass | su -c 'shutdown -r now'";
$output = array();
try{
echo shell_exec($command);
exec($command, $output);
system($command, $output);
}Catch(Exception e){
print "Unable to shutdown system...\n";
}

foreach ($output as $line) {
print "$line<br>";
} 
?>

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

here is my full code and it's working i have tested

//laravel-worker.conf

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/vagrant/Code/Laravel/artisan queue:work redis --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/home/vagrant/Code/Laravel/storage/logs/worker.log

// from https://laravel.com/docs/5.3/queues#supervisor-configuration



// server.js
require('dotenv').config();

const server = require('http').Server();

const io = require('socket.io')(server);

const Redis = require('ioredis');

const redis = new Redis();

redis.subscribe('all-channel');

console.log(process.env.SOCKET_PORT);

redis.on('message', function (channel, message) {
    const event = JSON.parse(message);
    io.emit(event.event, channel, event.data);
});

server.listen({
    port: process.env.SOCKET_PORT
});



// bootstrap.js
import Echo from "laravel-echo"

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: 'http://homestead.app:6001'
});


// home.blade.php
 
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script src="{{ elixir('js/app.js') }}"></script>

<script>

    document.onreadystatechange = () => {
        if (document.readyState === 'complete') {
            console.log("doc is ready");
            Echo.channel('all-channel').listen('ServerCreated', function(e) {
                console.log(e);
            });
        }
    };

</script>



/// route/web.php


Route::get('publish', function () {
    $data = [
        'type'    => 'erhelloror',
        'title'   => 'new article has been published',
        'message' => 'check it out',
        'url'     => 'url',
    ];
    event(new \App\Events\ServerCreated($data));
    return 'done';
});



/// App\Events\ServerCreated
// event

class ServerCreated implements ShouldBroadcast
{

    use InteractsWithSockets, SerializesModels;

    public $data;


    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(array $data = [])
    {
        $this->data = $data;
    }


    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('all-channel');
    }

}


17th November, 2016

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

@geraldarcega can you provide more information

16th November, 2016

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

Hi @andfelzapata i think the missing part in your node server

// need to add 'channel' like bellow 
io.emit(emmitChannel, channel, notificacion.data);

15th November, 2016

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

also in the frame you can see the entire event namespace or just a number ?

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

What about

echo.channel('channel-notificaciones')
    .listen('BecaCargada', function(e) {
        console.log(e);
});

khaledSMQ left a reply on Laravel Echo Listening Is Not Receiving Data • 1 year ago

Your welcome , sorry for late update. i think the problem is you have to listen for the jobs by running

php artisan queue:listen

Edit Your Profile
Update

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