samedi 28 octobre 2017

artisan output one by one

If I run php artisan migrate:fresh --seed --force in console everything works as expected. The output is displayed one by one.

Dropped all tables successfully.

Migration table created successfully.

Migrating: 2014_10_12_000000_create_users_table

Migrated:  2014_10_12_000000_create_users_table

Seeding: UsersTableSeeder

etc.

If I run the artisan command from Laravel everything work fine excepting the output. It is displayed once at the end with all of the actions.

$this->info('Migrating and seeding the database...');
Artisan::call('migrate:fresh', [
    '--seed'  => true,
    '--force' => true,
]);
$this->line(Artisan::output());

I am looking for a method to display Artisan::output() one by one for each table (the same behaviour like running the command in console).



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ycvUTN
via IFTTT

Laravel Forge with AWS nginx 404

I have started a laravel forge server with AWS, and added my laravel site which points to /public.

Now when I get to the site via ip I get 404 nginx error

here's my default nginx configuration:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/http://ift.tt/2zdv7C9;

server {
    listen 80;
    listen [::]:80;
    server_name przemek-wojtas.co.uk;
    root /home/forge/http://ift.tt/2iJnDjf;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-$
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/http://ift.tt/2zdv8Gd;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

I don't know what is wrong, I just used laravel forge to create new server, and created a new site from my git repository which works absolutely fine



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iJnEUl
via IFTTT

Laravel job dumps exec() error into command line instead of $output

I am trying to build a simple deployer in Laravel, that will receive a webhook, perform a deployment and store some information (from the hook) about said deployment.

I am using Laravel 5.2 jobs dispatcher to perform the following:

public function deploy()
{
    $result = 0;
    $output = array();
    exec('cd ' . $this->deploymentMapping->full_file_path . '; git pull', $output, $result);
    return array(
        'result' => $result,
        'output' => $this->outputToString($output)
    );
}

My understanding of the exec() function is that this should not dump any errors directly, but will store them in $output.

However, when I run php artisan queue:work on my server in the command line, to test the job dispatcher, I just immediately get fatal: Not a git repository (or any of the parent directories): .git dumped into the command line output. This git error is correct, but it is making the job "fail" as though exec() threw an error. Is this correct? My job should be reporting the error in its own way, as follows:

public function handle()
{
    $deploymentAttempt = new DeploymentAttempt();
    $deploymentAttempt->deployment_id = $this->deploymentID;
    $gitResponse = $this->deployer->deploy(); //the above function
    $deploymentAttempt->success = !($gitResponse['result'] > 0);
    $deploymentAttempt->message = $gitResponse['output'];
    $deploymentAttempt->save();
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iIbxXV
via IFTTT

Dynamic dropdown with Ajax from one table in Laravel

I am trying to make a drop down list that update the URL when choosing a city like that :

http://Localhost:8000/Victoria/Melbourne

But the URL always update with empty arrays like that :

http://localhost:8000/[ ]/[ ]

How can i fix that please ?

My table structure like below :

database strutcture

My blade html and Ajax code :

<select id="country_name_id" class="countryName form-control">

                    @foreach ($countries as $country) 

                        <option></option>

                    @endforeach

                </select>

                <br>

                <select class="regionName form-control">

                    <option value="0" disabled="true" selected="true">Choose Region</option>

                </select>

                <br>

                <select id="city_select" class="cityName form-control">
                    <option value="0" disabled="true"selected="true">Choose City</option>

                </select>

My routes :

Route::get('/findRegionName', 'HomeController@findRegion');

Route::get('/findCityName', 'HomeController@findCity');

Route::get('/{regions}/{cities}', 'HomeController@store')->name('user.location.store');

My Home controller :

class HomeController extends Controller
{

public function index(Request $request)

{
    $countries = Location::select('country_name')->groupBy('country_name')->get();

    $regions = self::findRegion($request);

    $cities = self::findCity($request);

    return view('home', compact('countries','regions','cities'));

}

public function findRegion(Request $request)

{
    $data=Location::select('region_name')->groupBy('region_name')->where('country_name',$request->country_name)->distinct()->get();

    return $data;
}

public function findCity(Request $request)

{        
       $data=Location::select('city_name')->groupBy('city_name')->where('region_name',$request->region_name)->distinct()->get();

    return $data;
}

public function store()

{
}

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2loT0ki
via IFTTT

Laravel Blade templates superglobal variables

How to use variables

  • $_GET
  • $_POST
  • $_SERVER
  • and so on

in Laravel Blade templates engine?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ySFN8I
via IFTTT

Live Searching Option in LARAVEL php Homestead

In Laravel PHP, I wrote a code for "Live searching option". but it was returning the query from Database.I have provided the code below for Search Controller which I have handled separately.

public function search(Request $q)
{
    $prD= DB::table('products')->get();
    $arrPname = array();
    $arrPprice= array();
    $arrPdetail= array();
    $arrPimage= array();
    foreach ($prD as $prod) {
    $arrPname[]= $prod->pname;
    $arrPprice[]=$prod->price;
    $arrPdetail[]=$prod->details;
    $arrPdetail[]=$prod->details;
    $arrPimage[] = $prod->image;}

    $q = Input::get ( 'q' );
    $products = DB::table('products')-> where('pname','LIKE','%'.$q.'%')->get();
     if(count($product) > 0)
       return view ('search',compact("arrPname","arrPprice","arrPdetail","arrPimage"));
       /*return view (('search')->withDetails($product)->withQuery ( $q )*/
     else return view ('home')->withMessage('No Details found. Try to search again !');
    }

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zeGE4i
via IFTTT

required field if other field doesn't have specific value

I have a field project which is required if account_name field doesn't have the value '0'.I want to validate this scenario in laravel eg if account_name = '0' -project_name field is not required if account_name = '1' - project_name field is required

 $this->validate($request,[
     'project_name'=>'required_without:account_name,0',
    ]); 



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zOqmvb
via IFTTT