mercredi 24 février 2016

Start new project with an exsiting laravel project

I have a local laravel 5.1 project A, I want to use it as a startup of a new project B. So, how can I use project A to start project B in the same localhost ? I did copy of A and rename its folder to B, create its new DB but it doesn't work :/ Please any idea ?



via Chebli Mohamed

Laravel 5.1 AuthController contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods

I have deleted the vendor folder and recreated it using composer install yesterday and it was working fine (probably cached). Today I'm facing this error.

FatalErrorException in AuthController.php line 84: Class enterglobe\Http\Controllers\Auth\AuthController contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (enterglobe\Http\Controllers\Auth\AuthController::toArray, enterglobe\Http\Controllers\Auth\AuthController::getKey, enterglobe\Http\Controllers\Auth\AuthController::getTable, ...)

I tried deleting it and installing, also composer dump-autoload also cleared composer cached files to install another version of laravel but with no success.

The error disappears if i just implement the methods on this class for example

public function toArray(){}
public function getKey() 
etc...

Error goes away from AuthController but then it appears in other controllers.

Anyone faced this before.



via Chebli Mohamed

Multiple property Full-Text Search with MongoDB in Laravel

I am using MongoDb with laravel.

Below is my users collection sample json data

{
    "_id" : "52dfcd17daf02a2e6cb396c7",
    "email" : "nikhil@gmail.com",
    "name" : "Nikhil"
}
{
    "_id" : "52e0f9a2daf02ac908064f68",
    "email" : Michael@gmail.com,
    "name" : "Michael"
}

I have created index for 2 columns in collection, which is name & email.

db.users.ensureIndex({'email':'text', 'name': 'text'})

When i search for name I get the data but when i search exactly for an email id it gives unexpected results which should have been the emailId record.

Here is my code

$users = Users::whereRaw(['$text' => ['$search' => 'example@gmail.com']])->paginate(20);

return response()->view('users.view',
[
      'users' => $users,
      'title' => 'Search results for your query: ' . $query
]);



via Chebli Mohamed

Laravel 5.2: While moving to production, class "Collective\Html\HtmlServiceProvider" not found in vendor folder

I have been trying to move my laravel app to production. I following below steps

1. git clone
2. composer install
3. set env variables
4. (artisan key:generate)
5. artisan migrate --seed

But when i ran composer install, am getting the following error

Class 'Collective\Html\HtmlServiceProvider' not found in vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

I know this error means, laravelcollective not added in composer.json and need to following steps as mentioned here.

But i already have done the same thing in dev mode and now the composer.json has require "laravelcollective" and aliases in config/app.php.

My question is, do i need to the same thing what i have done in dev (resolving laravelcollective issue) for every new production instance that i am gonna set it up ?



via Chebli Mohamed

mardi 23 février 2016

find in set in laravel ? example

I am new in laravel. My query is i need to find out value from comma separated field.

Here is my table.

Table name :- tags_value

| id  | tags         
| --- | ------------ 

| 1   | css,html,php 

| 2   | php,java,css      

| 3   | java,c++,ios 

My sql query :-

 $query = DB::table('tags_value')
          ->whereRaw(FIND_IN_SET('css',Tags))
          ->get();

but its not working.

Please help me for solve this problem.

Thanks in advance



via Chebli Mohamed

Curl request to twitter API using laravel 5.1

just start using curl don't know much about it i am trying to send a request to twitter API using laravel 5.1 through Curl that's my Controller code

public function getTwitterLogin($auth=NULL){
    if($auth == 'auth')
    {
        Hybrid_Endpoint::process();
        return;
    }
    try{
        $oauth=new Hybrid_Auth(app_path(). '/config/twitterAuth.php');
        $provider=$oauth->authenticate('Twitter');
        $client->getHttpClient()->setDefaultOption('verify', 'D:\General software');
       //curl_init();
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'https://api.twitter.com/1.1/users/search.json');
        $result = curl_exec($curl);
          var_dump($result);

i downloaded a curl folder from curl website and place the curl.exe file in D:\General software and changed the environment variable path also but now its replying that Undefined variable: client



via Chebli Mohamed

Sending info from database to SideNavigation blade through BaseController is good?

I have Layout Page that has following blade references.

<!DOCTYPE html>
<html lang="en">
<head>
    @include('Includes.head')                    //reference - 1
</head>
<body class="nav-md">
    <div class="container body">
        <div class="main_container">
            @include('Includes.topheader')       //reference - 2
            @include('Includes.sideNavigations') //reference - 3
            @yield('content')
            @include('Includes.footer')          //reference - 4
        </div>
    </div>
    @include('Includes.footerscripts')           //reference - 5
</body>
</html>

I want to send list of record to Side navigation. Can somebody suggest if I should use Base Controller



via Chebli Mohamed