Laravel 5: Action not defined

I searched a little on the internet, I found some topics that spoke about this, but none about my problem specifically.

So my error:

Action App\Http\Controllers\Users@index not defined.

The controller Users:

<?php
namespace App\Http\Controllers;

use Illuminate\Routing\UrlGenerator;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Input;
use App\Models\Users;
use Session;
use Validator;

    class Users extends Controller {

     protected $users;


     public function __construct(Users $users)
     {
             $this->users = $users;
     }

    public function index()
    {
        $data['limit']=$limit;
        $data['title']='Liste des Utilisateurs';

        $data['result']=$this->user->user_list($limit);

        return view('user_list', $data);
    }

The routes:

Route::get('users/{limit?}', function($limit = 0, Request $request)
{
  if(Auth::check()){
    return redirect()->action('Users@index');
  }else{
    $request->session()->flash('message', 'Vous devez vous connecter avant de pouvoir accéder à la plateforme.');
    return redirect('login');
  }
});

Best regards

Advertisements

Symfony 4, doctrine, getResult and getArrayResult and getScalarResult return same structure results

From symfony 4, I create a sample repository class. From this class, I created a method for get the list of all email’s users. I would like get a array structure like this :

array(
    "email1",
    "email2",
    "email3",
    ...       
)

But with ‘getResult’ I get a multidimensional array. Then, I tested with getArrayResult and getScalarResult and I obtain each time exactly the same array structure result !

Below, my Service Class :

<?php
class UserRepository extends ServiceEntityRepository
{
    public function __construct(RegistryInterface $registry)
    {
        parent::__construct($registry, User::class);
    }

    public function getAllEmail(){
        $result = $this->createQueryBuilder('u')
            ->select(array('u.email'))
            ->setMaxResults(5)
            ->getQuery();
        return array( // getResult && getArrayResult && getScalarResult return exactly same array structure
            "getResult" => $result->getResult(),
            "getArrayResult" => $result->getArrayResult(), 
            "getScalarResult" => $result->getScalarResult(),
        );
    }
}

And the result when I dump the output of “getAllEmail()” :

enter image description here

Why getResult / getArrayResult / getScalarResult return exactly same array structure ? I do a mistake somewhere ?

Formating errors on Slack using spatie/laravel-slack-slash-command package Laravel 5.5

I am using a package spatie/laravel-slack-slash-command and the code below works fine except for this condition if the user inputs no argurment, there’s an error being caught because there’s a CatchAll.php class in the package, I would simply like to know how to format this error, thanks!

Error

This is how I would like to format the error

 if (empty($slack_request))
    {
       return $this->respondToSlack("Argument Missing")
            ->withAttachment(Attachment::create()
            ->setColor('warning')
            ->setText("You must provide two digits between 00 and 13 after ex : /tasks day {00}")
        );
    }

Here’s the full Class

<?php

namespace App\SlashCommandHandlers;

use Spatie\SlashCommand\Attachment;
use Spatie\SlashCommand\AttachmentField;
use Spatie\SlashCommand\Handlers\SignatureHandler;
use Spatie\SlashCommand\Request;
use Spatie\SlashCommand\Response;
use App\Models\Retry42\Project;

class Projects extends SignatureHandler
{
    protected $signature = 'tasks day {day}';

  public function handle(Request $request): Response
  {

    $slack_request = $this->getArgument('day');

    if (empty($slack_request))
    {
       return $this->respondToSlack("Argument Missing")
            ->withAttachment(Attachment::create()
            ->setColor('warning')
            ->setText("You must provide two digits between 00 and 13 after ex : /tasks day {00}")
        );
    }

    if(!preg_match("/^(0[0-9]|1[0-3])$/", $slack_request))
    {
        return $this->respondToSlack("Invalid argument, two digits between 00 and 13")
            ->withAttachment(Attachment::create()
            ->setColor('warning')
            ->setText("Project day must be two digits between 00 and 13")
        );
    }

    $day =  $slack_request;

    $project = 'Day '.$day;

    $project = Project::where('name', '=', $project)->firstOrFail();

    $tasks = $project->tasks->toArray();

    if (!count($tasks)) {
         return $this->respondToSlack("Sorry we could not get you any tasks for Day {$day}")
            ->withAttachment(Attachment::create()
            ->setColor('warning')
            ->setText("Try another day!")
        );
    }

     $attachmentFields = collect($tasks)->reduce(function (array $attachmentFields, array $task) {
        $value = $task['description'] ?? '';

        if($task['visible'] == 1)
        {    
            $attachmentFields[] = AttachmentField::create('Name', $task['name'])->displaySideBySide();
            $attachmentFields[] = AttachmentField::create('Description', $value)->displaySideBySide();            
        }

        return $attachmentFields;
    }, []);

    return $this->respondToSlack("Here are the tasks for Day {$day}")
            ->withAttachment(Attachment::create()
            ->setColor('good')
            ->setFields($attachmentFields)
        ); 
  }
}

Drupal Website shows localhost error 500 after deployment

I have an already built drupal website which I am trying to deploy. I deployed it and it and run the mysql script for the DB. Now when I go to my website http:\localhost\mywebsite\install.php , it says site is already installed , click here to view your website, and when I click on that , It shows error 500.

Log file is emtpty.

I am trying to deploy it on Windows/IIS server, it was built on linux/apache2 server. It uses php7.

here is the zip file http://ift.tt/2CuOiWU

and you can try it on your side, Let me know if you can make it work on my windows IIS localhost.

Take many elements by pluck Laravel?

public function getPackage($type)
{
    $sale = Tour::where('id_package',$type)->get();
    $pack = Package::where('id',$sale->pluck('id_package'))->get();
    $loca = Location::where('id','=',$sale->pluck('id_location'))->get();
    return view('page.package',compact('pack','loca','sale'));
}

When i use dd($sale->pluck(‘id_location’), i can get two element but when I assign $loca to only one, and when I use whereIn(‘id’,$sale->pluck(‘id_location’) I can get two element but does not match the id tour @@

Thanks

can’t upload image to server godaddy

I’m sending a picture from the Android application to the server but tells me wrong path

when I clear this line it works but does not add an image

$path = "httpdocs/A-messages/stats/" . $imgname ;

all codes

 <?php
            $con=new mysqli("xxx","xxx","xxx","xxx");
            $con->query("SET NAMES utf8");
            $con->query("SET CHARACTER utf8");
            $hey = $_POST["hey1"];
            $imgname = "img_beta.jpg";
            $path = "httpdocs/A-messages/stats/" . $path;
            file_put_contents("$path", base64_decode("$hey"));
            $st=$con->prepare("insert into users(username) values(?)");
            $st->bind_param("s",$hey);
            $st->execute();   


    ?>

error page

enter image description here

maybe path wrong how I can get path I want send Image to stats folder