Home > database >  Laravel Backpack uppercase
Laravel Backpack uppercase

Time:09-06

I am trying to have a column where

  • the text is in upper case
  • and the column is orderable.

If I am doing this through an accessor, then this won't be a tableColumn and it won't be orderable. So this wont work.

Next I am trying to find a way to make it uppercase in blade? For example, I am setting a column->toUpper = true;

     $this->crud->addColumn(
        [
            'name'      => 'country',
            'label'     => 'Country,
            'type'      => 'text',
            'toUpper'   => true
        ]);

Where in blade can I search for this and transform the value?

Or how should I do this? Looks like an easy task but I cant find it in the docs.

CodePudding user response:

You can use

CRUD::column('text_and_email')
        ->type('model_function')
        ->label('Text and Email')
        ->function_name('getUpperText')

And add in model function

public function getUpperText() {
    return strtoupper($this->field);
}

CodePudding user response:

use Illuminate\Support\Str;

$string = Str::upper('QandeelAcademy');

Use this method when you are fetching the data from the database Read this

  • Related