Ghaleon

Experience

4,950

0 Best Reply Awards

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

12th September, 2017

Ghaleon left a reply on Can't Authenticate User • 1 week ago

I think that's normal for pluck. Because if I print them separetely it works fine, both email and password...

Ghaleon left a reply on Can't Authenticate User • 1 week ago

Told ya. I'm getting crazy with this, man. No idea what's causing it.

Route::post('/doLogin',['as' => 'doLogin', 'uses' => 'Auth\[email protected]']);  

Ghaleon left a reply on Can't Authenticate User • 1 week ago

Ghaleon left a reply on Can't Authenticate User • 1 week ago

Nop. Same as before =\

Ghaleon left a reply on Can't Authenticate User • 1 week ago

Done ! It's NULL

array:4 [▼
  "_token" => "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
  "email" => "[email protected]"
  "password" => "teste123"
  "action" => null
]

Ghaleon left a reply on Can't Authenticate User • 1 week ago

Hi, @tisuchi Thanks again !

Already checked. the form is method=POST. Unfortunatelly the strange behavior remains =(

Ghaleon left a reply on Can't Authenticate User • 1 week ago

@tisuchi Thanks for the reply ! As I mentioned, already checked the values from the variables and I'm getting the correct values.

Ghaleon started a new conversation Can't Authenticate User • 1 week ago

I'm struggling myself trying to find the reason but can't. I'm using sqliteand this is my code:

         $email              = $request['email'];
         $password       = $request['password'];

         if ( Auth::attempt(['email' => $email, 'password' => $password]) )
         {
             return redirect()->route('home');            
         }        
         return redirect()->back();

It just does not authenticate, always falls on the else part.

Possible cause of the problem ?

17th February, 2017

Ghaleon left a reply on Change Element Style According To Database Flags • 7 months ago

@tykus I was so focused to find a solution using Laravel stuff like Accessors that I was blind to everything else. So simple... Shame on me!

Thanks !!

Ghaleon started a new conversation Change Element Style According To Database Flags • 7 months ago

I have a table with a couple of flags:

Foo : Migration

Schema::create('foo', function(Blueprint $table)
   {
      $table->increments('id')->unsigned();                            
      $table->string('field_1', 10);
      $table->string('field_2', 10);
      $table->boolean('flag_1')->default(0);
      $table->boolean('flag_2')->default(0);
      $table->boolean('flag_3')->default(0);
      $table->timestamps();
    });    

I have a kind of complex query that I could not achieve using laravel's relationships, (BelongsTo, BelongsToMany, etc...). So I did inside Foo's Model like so:

public function myFunc($filterOne, $filterTwo)
   {
      SELECT
      table1.id, table1.name,
      table2.id, table2.week_day,            
      table3.id,
      table4.date
      FROM table1
      LEFT JOIN table2 ON table2.id = table1.table2_id
      LEFT JOIN table3 ON table2.table3_id = table3.id
      LEFT JOIN table4 ON table3.id = table4.table3_id
      WHERE table1.cod_field='.$filterOne.' AND table3.date = "'.$filterTwo . '"
   }    

What I need is: Everytime one of those flags are true, I need to call user's attention by changing the icon's color (that's what I found be the best way to do it).

As I'm using QueryBuilder instead of Eloquent I can not use Laravel's Accessors. Because $disc is not an instance of my Foo Model.

Here is my HTML with the icons in place:

@foreach($obj->myFunc($obj->field1, $obj->field2) AS $disc)
   <i class="{{ $disc->flag_1 }} flag fa fa-check fa-lg"></i>
   <i class="{{ $disc->flag_2 }} flag fa fa-camera-retro fa-lg"></i>
@endforeach

Instead of writing the flag's value (0 / 1) I want to write a CSS class. That way I could change it's color to call user's attention. But How ?

Obs1: I know I could make a way better database relations but unfortunatelly I can't play with it for this project. Database comes from my university and there are just a few things I can change.

15th February, 2017

Ghaleon left a reply on Accessor Returning 0 Instead Of String • 7 months ago

That random logic in model class was the only way I found to bring the data I needed with the database I have. Couldn't do it with belongsToMany and it's alike methods...

I'm building a system to my university and unfortunatelly there are just a few things I can change regarding database, and it's a really mess :(

That's why I'm using this ugly function to bring me the data I need. Any ideas how I could achieve that ? Maybe just help me with something to start...

Ghaleon left a reply on Accessor Returning 0 Instead Of String • 7 months ago

I see it now. I'm so dumb...

May I ask something one last time?Just to not create another thread:

I have a bunch of columns/flags in my database, they are booleans (1/0). For each column/flag, I created one icon

<i class="fa fa-camera-retro fa-lg"></i> //Flag 1
<i class="fa fa-camera-retro fa-lg"></i> //Flag 2...

Whenever this flags turns to be true, I need to call user's attention by highlighting the icon (I thought this would be the easier way).

As I can't use Eloquent/Accessors to do it, how may I achieve that? Any tips?

Ghaleon left a reply on Accessor Returning 0 Instead Of String • 7 months ago

@Snapey yes, sir. I'll show you the full code:

I have this function inside Foo Model: ( I edited the function, removing what I thought unecessary ).

public function myFunc()
    {
        return DB::select('
            SELECT 
            foo.cod_professor
            myClass.my_flag
            FROM foo
            LEFT JOIN myClass ON ...
        ');

This is how I access that method:

 @foreach($obj->myFunc() as $disc)

    <i class="{{ $disc->my_flag}} fa fa-camera-retro fa-lg"></i>
@endforeach

Inside Turma MODEL I wrote our code:

public function getMyFlagAttribute($value)
{
     return "myClass"; // or return an integer, still returning 0.
}    

Ghaleon left a reply on Accessor Returning 0 Instead Of String • 7 months ago

@Snapey Thanks for the explanation, but the problem remains... It still returning me 0 instead of my className. Even when I test something like this:

public function getTurmaNovaAttribute($value)
    {
        return 1;
    }

14th February, 2017

Ghaleon left a reply on Accessor Returning 0 Instead Of String • 7 months ago

@Snapey No problem to practically repeat the same code for different fields?

Ghaleon started a new conversation Accessor Returning 0 Instead Of String • 7 months ago

I have some flags in my database, each flag is represented with an Icon in my html page. I'd like to hightlight the icon when the flag is "on" to call user's attention.

I'm trying to do it using Accessors, like so:

public function __get($value)
    {
        if( in_array($value, ['Flag1', 'flag2' 'flag3']) ){  
            if($value == 1){
               return "new_Class";
            }
        }
        return $this->getAttribute($value);
    }  



//HTML PAGE  

<i class="{{ $disc->field_flag }} flag fa fa-camera-retro fa-lg"></i>

I have a problems:

The String returned from my function is 0 and not the string with the class name.

26th November, 2016

Ghaleon left a reply on Using Eager Loading And Ajax With Laravel • 9 months ago

@jekinney Thanks for the reply !

I'm using query builder because I could not execute that same query with eloquent ; Any tips ?

Ghaleon left a reply on Using Eager Loading And Ajax With Laravel • 9 months ago

@Snapey

Do I have to write the JS code inside PHP file ? I see that it's possible and even a common thing to do, but not highly recommended.

I'm asking because I don't think I can get the URL from my .js file.

Script.js

$('#selectSemestres').change(function(obj){
        var anoSemestre = $(this).val();
        $.ajax({
            type: 'GET',
            url: '',
            data: ...

        });
    })  

Should I have write it inside my php file ? No problem doing it ?

20th November, 2016

Ghaleon left a reply on Using Eager Loading And Ajax With Laravel • 10 months ago

@Snapey Hi. Thanks for replying.

I need to make a POST in order to pass data using Ajax. I already have a POST method to that route. To re-render the element (the list), I'd have to send a GET to the original URL, right ? Not sure how to do all of this.

Routes:


    Route::get('professor', [
    'as' => 'professor', 'uses' => '[email protected]'
    ]);

    Route::post('professor', [
        'as' => 'postProfessor', 'uses' =>            '[email protected]'
    ]);

Script.js

$('#selectSemestres').change(function(){
        $.ajax({
            type: 'POST',
            url: '???',
            data: $(this).val()
        });
    });

11th November, 2016

Ghaleon started a new conversation Using Eager Loading And Ajax With Laravel • 10 months ago

Hi ! I'd like to know if is it possible to use eager loading in a query that joins more than 2 tables, like so:

  public function turmas($codProfessor, $ano_semestre)
    {
        return DB::select('
           SELECT
           professor.cod_professor, professor.nome,
           horario.id, horario.cod_disciplina, horario.nome_disciplina, horario.dia_semana, horario.hr_inicio,
           horario.hr_fim, turma.id AS turmaID,
           professor_turma.id_turma
           FROM professor
           LEFT JOIN professor_turma ON professor_turma.cod_professor = professor.cod_professor
           LEFT JOIN turma ON professor_turma.id_turma = turma.id
           LEFT JOIN horario ON turma.id = horario.id_turma
           WHERE professor.cod_professor = '. $codProfessor.' AND turma.ano_semestre = "' . $ano_semestre . '"
           GROUP BY CONCAT(professor_turma.id_turma)
           ORDER BY professor.nome
       ');

I use the method above to echo the professor's disciplines on my view. Also I have a tag with a few year-semester values and everytime I chage this value, I need to reload the professors list and Theier disciplines. How may I do that? I was trying to use ajax with onChange event of the but I can't make it work because I need to pass the selected value to the function. Is there a way to reuse the way its beeing done and work around when no value is passed?

Controller

public function getProfessorList()
    {
        $professor = Professor::all();
        $semestres = Horario::distinct()->select('ano_semestre')->get()->toArray();
        return View::make('professor', compact('professor', 'semestres'));
    }

View

@foreach($professor as $key => $prof)
                    <div class="lock-holder">

                    <li>
                        <input type="checkbox" name="item" class="cb-prof" id="item{{ $key }}" />
                        <label for="" data-id="{{ $prof->cod_professor }}" >{{ $prof->cod_professor }} - {{ $prof->nome }}
                        </label>
                        <input type="checkbox" name='locker' id="locker{{$key}}" class="cb-lock" />
                       
                        

                        @if( count($prof->turmas($prof->cod_professor, $semestres[0]['ano_semestre'])) )
                            <ul class="prof-disciplinas">
                            @foreach($prof->turmas($prof->cod_professor, $semestres[0]['ano_semestre']) as $disc)
                                    <li data-dia="{{ $disc->dia_semana }}" data-startTime="{{ $disc->hr_inicio}}" data-id="{{ $disc->id_turma }}" data-endTime="{{ $disc->hr_fim }}">
                                        <a href="#">{{ $disc->nome_disciplina }}</a>
                                    </li>
                            @endforeach
                            </ul>
                        @endif
                    </li>
                    </div>
                @endforeach

10th October, 2016

Ghaleon left a reply on Redirecting The User If Not Authenticated • 11 months ago

@ahuggins Thanks for the reply !

No idea why, but php artisan make:auth gives me nothing but error. I'm implementing my own "auth system". Guess I found the problem: App/Http/Middleware/Authenticate.php

public function handle($request, Closure $next)
    {
        if ($this->auth->guest())
        {
            if ($request->ajax())
            {
                return response('Unauthorized.', 401);
            }
            else
            {
                return redirect()->guest('/login');  <- I JUST EDITED THIS
            }
        }

        return $next($request);
    }

Ghaleon started a new conversation Can't Check If User Is Authenticated • 11 months ago

I'm using laravel 5.0 and I'm trying to check if the user is authenticated. If he is, then he can proceed to the page. But if he is NOT authenticated, I wan to redirect him to my login page. Can't figure out what's wrong:

If I try to access http://localhost/chdps/public

Route::group(['middleware' => 'auth' ], function(){
    Route::get('/', [
        'as' => 'home', 'uses' => '[email protected]'
    ]);
});

Then the URL become: http://localhost/chdps/public/auth/login and I get an error:

NotFoundHttpException in compiled.php line 7959:

Don't know how to fix it. Already read what is in Authentication.

1st October, 2016

Ghaleon started a new conversation Can't Understand Laravel Authentication System • 11 months ago

I'm reading the Documentation of Laravel 5.0 also following some youtube tutorials and I can't understand somethings...

My Code BEFORE:

old Model

`<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model {

} `

old Controller

public function postsignin(Request $request) { if( Auth::attempt( ['email' => $request['email'], 'password' => $request['password'] ] ) ) return redirect()->route('dashboard'); return redirect()->back(); }

When I typed the wrong credentials, I was redirected OK. But when I typed the right credentials, I was receiving this error:

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given ...

Then I added the following code and it's working now:

new Model

`

3rd August, 2016

Ghaleon left a reply on Php Artisan Command Strange Return • 1 year ago

I use the same Git Bash prompt. The only difference here is that It's working in my old 5.0 laravel installation but it's messed up in my new 5.2 laravel installation.

Ghaleon left a reply on Php Artisan Command Strange Return • 1 year ago

What I meant is: In the first image, its all readable. But in the second one, you can't read anything, it's all messed up...

it's like the response time is showed and makes everything impossible to read.

Ghaleon started a new conversation Php Artisan Command Strange Return • 1 year ago

When I run php artisan with my laravel 5.0 installation, this is what I get:

http://imgur.com/a/XHVmL

But, when I run the same command within my fresh laravel 5.2 installation. This is what I get: http://imgur.com/a/22GsT

Any idea why ?

15th February, 2016

Ghaleon left a reply on Converting Data From Excel File • 1 year ago

@simondavies Thanks man ! You helped me a lot. It's working now --

12th February, 2016

Ghaleon left a reply on Converting Data From Database • 1 year ago

@simondavies I see, that's what I tried in the above post :P

The problem is with this 'maatwebsite excel to laravel'. It's messing up with my date format and I can't make it work the DATA cell without ruining my TIME cells ;\

Ghaleon left a reply on Converting Data From Database • 1 year ago

@simondavies

the results:

$date = \DateTime::createFromFormat('d-m-Y', $turma->dt_inicio_periodo);
echo $date->format('d/m/Y') . '<br>';

The data on cell: 01/04/2013 (dd/mm/yyyy)

the output: 04/01/0013 --> It inverted the day/month and instead of 2013 I get 0013 o.O

really weird

Ghaleon left a reply on Converting Data From Database • 1 year ago

@simondavies Thanks again ! (you can check the full code above)

This is what I have on excel cell: *01/04/2013*

#1

echo $value['dt_inicio_periodo']       //Output: 04-01-2013  -> Right date, wrong format   
echo $turma->dt_inicio_periodo   //same as above /\

#2

$date = new \DateTime($value['dt_inicio_periodo']);
echo $date->format('d/m/Y') . '<br>';  //Output: 13/01/2004 (this date does not exists in my excel file o.O )

Number #2 example, after some prints give me this error:
DateTime::__construct(): Failed to parse time string (03-14-13) at position 0 (0): Unexpected character

Ghaleon left a reply on Converting Data From Database • 1 year ago

@simondavies Hi !

I'm 90% sure the first problem was indeed caused by the method used to capture the data from excel file (maatwebsite).

Thoug, I still need to format a DATE this time. I'm getting this date format: dd-mm-yyyy I need to convert it to dd/mm/yyyy to store in database. With Carbon, it says that the given string is NOT a valid date.

Any thoughts?

10th February, 2016

Ghaleon left a reply on Converting Data From Database • 1 year ago

@simondavies Thanks for the reply. The field is already set as TIME ;s

Ghaleon left a reply on Converting Data From Database • 1 year ago

@JoeDawson Sorry '-' updated !

Ghaleon started a new conversation Converting Data From Database • 1 year ago

Hi !

I have an excel file with TIME only, but when I try to insert it into database or even just echo it I'm getting today's date with it. Example:

Data from excel:
13:30:00
14:30:00
17:30:00

But I'm getting this:

2016-02-10 13:30:00
2016-02-10 19:30:00
2016-02-10 19:10:00

Already read This
And following the documentation, I did this with no results:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Turma extends Model
{   
    protected $dateFormat = 'U';

    public function disciplinas()
    {

    }

}

5th February, 2016

Ghaleon left a reply on Customizing Prefix In URLs • 1 year ago

@premsaurav Only laravel '-'

Ghaleon started a new conversation Customizing Prefix In URLs • 1 year ago

I have this html:

    <ul>
       <li><a href="index.php/Page1">Page 01</a></   
       <li><a href="index.php/Page2">Page 02</a></li>
      <li><a href="index.php/Page3">Page 03</a></li>
    </ul>  

As you can see, I need to use the index.php/prefix in all links due to the server of my university (I can't change it). The way is done above, it works fine to go straightfoward from home to any page, but if I try to access a page from another page, I get a wrong URL and Can't access the page:

Examples:

Home
http://localhost/php-project/public/

Page1 (From home)
FROM: http://localhost/php-project/public/
TO: http://localhost/php-project/public/index.php/Page1

Page2 (From home)
FROM: http://localhost/php-project/public/
TO: http://localhost/php-project/public/index.php/Page2

Page1 (From Page2)
FROM: http://localhost/php-project/public/index.php/Page2
TO: http://localhost/php-project/public/index.php/index.php/Page1

as you can see, the prefix repeats itself. I have no idea how to do it to work right.

Any ideas?

19th November, 2015

Ghaleon started a new conversation Customize A Query In Model • 1 year ago

I have a table with three important keys that I need to Inner Join with two other tables. MY currently code:

class Professor extends Model
{
    protected $table = "professor";
    protected $primaryKey = 'cod_professor';

    public function turmas()
    {
        return $this->belongsToMany('App\Turma',professor_turma','cod_professor', 'cod_turma')->withPivot('CH','ano_semestre');
     }
}

I Wrote the sql manualy to test, how may I make laravel query something like this:

SELECT DISTINCT professor.nome, professor_turma.cod_professor, professor_turma.cod_turma, professor_turma.cod_disciplina, turma.nome_disciplina
FROM professor_turma
INNER JOIN professor ON professor_turma.cod_professor = professor.cod_professor
INNER JOIN turma ON professor_turma.cod_turma = turma.cod_turma AND professor_turma.cod_disciplina = turma.cod_disciplina
WHERE professor_turma.cod_professor =  ?

On WHERE professor_turma.cod_professor = ? I need to loop through all() my professors.

18th November, 2015

Ghaleon left a reply on Many-to-Many Relation Not Getting The Related Table Data • 1 year ago

@arnabrahman Thanks man. But I can't do that. I do not have a table connecting discipline and professor

    public function teachesDisciplines()
    {
        return $this->belongsToMany('App\Discipline','professor_discipline');
    }

My table professor_turma has the keys cod_discipline, cod_turma, cod_professor.
My table turma has the keys: cod_discipline, cod_turma.

I need to conect it and also get the name of the professor through the professor table.

17th November, 2015

Ghaleon left a reply on Many-to-Many Relation Not Getting The Related Table Data • 1 year ago

@arnabrahman Like this ?

class Turma extends Model
{
    protected $table = 'turma';
    protected $primaryKey = 'cod_turma';

    public function index()
    {
        return $this->belongsToMany('\App\Professor', 'professor_turma', 'cod_turma', 'cod_turma');
    }

}

class Disciplina extends Model
{
    protected $table = "disciplina";
    protected $primaryKey = 'cod_disciplina';

    public function index()
    {
        return $this->belongsToMany('App\Professor', 'professor_turma','cod_disciplina', 'cod_disciplina')->withPivot('CH','ano_semestre');
    }
}

I guess there goes the same field name because it's the same name both in Turma / Disciplina table AND on the Professor_turma table.

16th November, 2015

Ghaleon left a reply on Many-to-Many Relation Not Getting The Related Table Data • 1 year ago

@arnabrahman Thanks for the help.

They are both empty. I just specified the $table and $primaryKey.

Its kind of hard to explain. I don't have a commom relation between these tables.

professor_turma

cod_disciplina cod_turma cod_professor ano_semestre ch

disciplina

cod_disciplina name ...

turma

cod_disciplina nome_disciplina cod_turma ...

My professor_turma table has those three keys (cod_turma, cod_disciplina, cod_turma), I need to use these three values to identify a single turma that has a specific discipline that is taught by a professor.

Ghaleon left a reply on Many-to-Many Relation Not Getting The Related Table Data • 1 year ago

@arnabrahman Sorry, I was testing. I replaced it with

    public function turmas()
    {
        return $this->belongsToMany('App\Turma', 'professor_turma','cod_professor', 'cod_turma')->withPivot('CH','ano_semestre');
    }

Ghaleon started a new conversation Many-to-Many Relation Not Getting The Related Table Data • 1 year ago

I don't have a conventional relation between some of my tables (can't change it, I NEED the way it is).
I have a table professor_turma that have some data from Discipline and from Turma tables.

Here is my code:

My Model

class Professor extends Model
{
    protected $table = "professor";
    protected $primaryKey = 'cod_professor';
   
 
    /**
     * Busca as turmas associadas com um dado professor.
     */
 
    public function turmas()
    {
        return $this->belongsToMany('App\Turma', 'professor_turma', 'cod_professor', 'cod_professor')->withPivot('CH','ano_semestre');
    }
 
    public function disciplinas()
    {
        return $this->belongsToMany('App\Disciplina', 'professor_turma')->withPivot('CH','ano_semestre');
    }
}

My Controller

class ProfessorController extends Controller
{
    public function getProfessorList()
    {
        $professor = \App\Professor::all();
        return View::make('professor', compact('professor')); 
    }

My View

@foreach($professor as $prof)
    <li>
      <h3 data-id="{{ $prof->cod_professor }}" class="prof-name">{{ $prof->cod_professor }} - {{ $prof->nome }}
         <input type="checkbox" name="" value="" class="check_prof" />
      </h3> 
      @if (count($prof->turmas))
               <ul class="list-disc">
                  @foreach($prof->turmas as $disc)
                     <li data-dia="{{ $disc->dia_semana }}" data-time="{{ $disc->hr_inicio}}" data-id="{{ $disc->cod_disciplina }}">{{ $disc->nome_disciplina }}</li>
                 @endforeach
              </ul>
         @endif
       </li>
@endforeach

I'm able to print the professor->name. But when i try to use $prof->turmas-> in the second foreach. All that is printed is the query like this:

string(317) "select turma.*, professor_turma.cod_professor as pivot_cod_professor, professor_turma.CH as pivot_CH, professor_turma.ano_semestre as pivot_ano_semestre from turma inner join professor_turma on turma.cod_turma = professor_turma.cod_professor where professor_turma.cod_professor = ?"

As you can see, it only shows the query instead the data. I have no idea why..

10th November, 2015

Ghaleon started a new conversation Inserting Multiple Times The Same Data Into Database • 1 year ago

I'm reading an excel file and inserting it's data into my database. But it's inserting duplicate/triplicate/quad... the same data and I have no idea why.

My Code:

My View
<div class="container">
   <div class="row">
     {!! Form::open(array('url' => route('teste'))) !!}
        {!! Form::file('filename')!!}
        {!! Form::submit('Importar') !!}                
      {!! Form::close() !!}
   </div>
</div>
MY Controller
class ImportController extends Controller
{
    public function importProfessorTurma(Request $request){
        $table = new import_temp();
        $table->importa_dados($request->input('filename'));
   }
}
My Model

class import_temp extends Model { protected $table = "professor_turma";

public function importa_dados($name){
    Excel::selectSheets('professor_turma')->load($name, function($reader) {
        $reader->ignoreEmpty();
        $results = $reader->get()->toArray();
        foreach($results as $key => $value){
            $table = new import_temp();
            $table->cod_disciplina = $value['cod_disciplina'];
            $table->cod_turma = $value['cod_turma'];
            $table->cod_professor = $value['cod_professor'];
            $table->ano_semestre = $value['ano_semestre'];
            $table->ch = $value['ch'];
            $table->save();
        }
    })->get();
}

}

31st October, 2015

Ghaleon left a reply on Pass Filename From View To Controller • 1 year ago

@jlrdw Thanks ! And is the flow correct? View -> Route -> Controller ?

Ghaleon started a new conversation Pass Filename From View To Controller • 1 year ago

I have a form in my view and what I need to select a file with input file, this file will be an excel file and I need to read it and store it's content into my database.

######What I think is the right thing to do:

  • Select the file with input file;
  • Use the submit button to pass the filename to a method;

######How I think it should be done:
View --> Route --> Controller@Method

  • Select file with input file;
  • Form / Submite will redirect me to a specific route;
  • This route will have the method that I need to work with the file;

If I'm right, then I only need some help to pass the file name selected with input file to my route/Controller method.
If this is not the right way to go, please give me a tip, show me the light.

######MyView`:

{!! Form::open(array('url' => 'MyRouteNameOrPath')) !!}
    {!! Form::file('Import')!!}
    {!! Form::submit('Importar') !!}                
{!! Form::close() !!}

I don't know how to get the filename and pass it to the Route/Controller.

29th October, 2015

Ghaleon started a new conversation Insert Data Into Multiple Tables • 1 year ago

Hi !

I'm reading an excelFile.xls with a lot of data, the thing is that some of this data need to be inserted into Table A and some into Table B or into Table C.
As I'm not going to insert into a single table, I don't think I should use a model.

So what's the right way to insert data into multiple tables ??

23rd October, 2015

Ghaleon started a new conversation Laravel Excel Returning Only NULL Values • 1 year ago

I have an excel.xls file type: Microsoft Excel 97-2003 and when I try to read that using maatwebsite excel, I get only NULL values, here is my code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
Use Excel;
class ImportController extends Controller
{
    public function index()
    {
        $result = Excel::load('teste.xls')->all();          
        var_dump($result);
    }    
}

When checking the var_dump, I can see a lot of rows returning but all with the same code:

object(Maatwebsite\Excel\Collections\RowCollection)#633 (2) { ["title":protected]=> string(9) "Worksheet" ["items":protected]=> array(161) { [0]=> object(Maatwebsite\Excel\Collections\CellCollection)#645 (2) { ["title":protected]=> NULL ["items":protected]=> array(1) { [0]=> NULL } } [1]=> object(Maatwebsite\Excel\Collections\CellCollection)#655 (2) { ["title":protected]=> NULL ["items":protected]=> array(1) { [0]=> NULL } } [2]=> 

I did everything that says in the website:

1) Executed the command:

composer require "maatwebsite/excel=~2.0"  

2)Wrote this on providers in myProject/config/app.php
'providers' => ['Maatwebsite\Excel\ExcelServiceProvider', ... ] 'aliasas' => ['Excel' => 'Maatwebsite\Excel\Facades\Excel', ...]

3)Published without errors:
php artisan vendor:publish

Ghaleon left a reply on URL Rewrite • 1 year ago

@ericbarnes Thanks for answering, but that code gave me this result:

== http://localhost/public/css/style.css

22nd October, 2015

Ghaleon started a new conversation URL Rewrite • 1 year ago

Hi ! I'm using masterpage and I'm having problem with css/js files, because I can't use URL Rewrite.
So when I access the main page I'm redirect to:

http://localhost/myproject/public
So I link the css like this:

<link rel="stylesheet" href="{{ URL::to('/css/style.css') }}" />

BUT, when I need to access others pages I need to do this:

http://localhost/myproject/index_php/otherPage

then I need to link again the same css file, but this time I need to do this:

So of course it gives me error because it can't find the first call of this css file.
Any nice & clean solution ?

14th October, 2015

Ghaleon started a new conversation Can't Enable Rewrite URL. Any Solution ? • 1 year ago

Hi !

I just uploaded my files to my university's server and they do not allow Rewrite URL -.-"

So, this does not work:

www.mySite/usr/professor <--- usr = public folder

I have to write like this to access that page:
www.mySite/usr/index.php/professor <-- 404 Not Found on Every .js and .css files.

So I have two problem:

  • Can't find my .css & .js files;
  • How would I write the new URLs on my links ?

I was using something like this:

<li><a href="{{ URL::route('professor') }}">Professor</a></li>

It would take me to: http://mySite/usr/professor

Anyone could show me a solution for my problem IF there is any. Or should I just give up on laravel ... ? ;\

Edit Your Profile
Update

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