lundi 1 janvier 2018

How to update tinymce data from database using laravel

I'm having a trouble here guys hope you can help me.

The tinymce works absolutely fine when saving it to the database, the problem is when i try to retrieve it i using this {!! !!} nothing shows. how can i print the data from the database back to textarea tag of tinymce the way i design it so that i can redesign it again and again.

edit.blade.php:

<li class="step">
            <div data-step-label="Lesson Layout" class="step-title waves-effect waves-dark">Step 2</div>
            <div class="step-content lesson-editor">
             <div class="row">
               <div class="input-field col s12">
                 <textarea id="mytextarea editor" name="editor" rows="8" cols="80" value=""></textarea>
               </div>
             </div>
             <div class="step-actions">
               <button class="waves-effect waves-dark btn blue next-step" >CONTINUE</button>
               <button class="waves-effect waves-dark btn-flat previous-step">BACK</button>
             </div>
            </div>
          </li>

tinymce script:

selector: "textarea",
      height: '350px',
      plugins: [
          "advlist autolink lists link image charmap print preview hr anchor pagebreak",
          "searchreplace wordcount visualblocks visualchars code fullscreen",
          "insertdatetime media nonbreaking save table contextmenu directionality",
          "emoticons template paste textcolor colorpicker textpattern"
      ],

pardon me for my bad english.
thanks guys!



via Chebli Mohamed

How to Create a pattern for URL parameters in Laravel

I wrote this code in file RouteServiceProvider.php that is located in app/Providers directory. in method boot:

$this->pattern('{id}', '[0-9]+');

then according to what I read, I thought if I write this code:

Route::get('/user/{id}', function ($id){ return $id; });

in file web.php in routes directory the id parameter accept just int value, but when i test this url: http://ift.tt/2ly1KlU I saw a is returned. Now the question is:

  1. where is the problem?

2.how can I make pattern?



via Chebli Mohamed

storedAs column modifier not working in laravel 5.5 migration

I'm trying to add a virtual (persistent) column to my table in Laravel 5.5 using a regular migration:

public function up() {
    Schema::create('works', function (Blueprint $table) {
        $table->increments('id');
        $table->string('cat_name');
        $table->string('cat_prefix');
        $table->unsignedSmallInteger('cat_number');
        $table->string('cat_suffix');
        $table->string('catalog')->StoredAs(
            "concat(cat_name, ' ', cat_prefix, cat_number, cat_suffix)");
        $table->string('title');
    });
}

I have setup logging for all database queries in the project, so I can see the queries performed for php artisan migrate:fresh. The relevant query for the works table is logged as (formatting is mine):

create table `works` (
    `id` int unsigned not null auto_increment primary key,
    `cat_name` varchar(191) not null,
    `cat_prefix` varchar(191) not null,
    `cat_number` smallint unsigned not null,
    `cat_suffix` varchar(191) not null,
    `catalog` varchar(191) not null,
    `title` varchar(191) not null
) default character set utf8mb4 collate utf8mb4_unicode_ci

And indeed, looking at the description of the table in the database:

MariaDB [evh_site]> desc works;
+------------+----------------------+------+-----+---------+----------------+
| Field      | Type                 | Null | Key | Default | Extra          |
+------------+----------------------+------+-----+---------+----------------+
| id         | int(10) unsigned     | NO   | PRI | NULL    | auto_increment |
| cat_name   | varchar(191)         | NO   |     | NULL    |                |
| cat_prefix | varchar(191)         | NO   |     | NULL    |                |
| cat_number | smallint(5) unsigned | NO   |     | NULL    |                |
| cat_suffix | varchar(191)         | NO   |     | NULL    |                |
| catalog    | varchar(191)         | NO   |     | NULL    |                |
| title      | varchar(191)         | NO   |     | NULL    |                |
+------------+----------------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)

Manually creating a similar table in the database (MariaDB 10.0.31) with the right create syntax does work:

create table `works2` (
    ...
    `catalog` varchar(191)
        as (concat(cat_name, ' ', cat_prefix, cat_number, cat_suffix))
        persistent,
    ...

It results in:

MariaDB [evh_site]> desc works2;
+------------+----------------------+------+-----+---------+----------------+
| Field      | Type                 | Null | Key | Default | Extra          |
+------------+----------------------+------+-----+---------+----------------+
| id         | int(10) unsigned     | NO   | PRI | NULL    | auto_increment |
| cat_name   | varchar(191)         | NO   |     | NULL    |                |
| cat_prefix | varchar(191)         | NO   |     | NULL    |                |
| cat_number | smallint(5) unsigned | NO   |     | NULL    |                |
| cat_suffix | varchar(191)         | NO   |     | NULL    |                |
| catalog    | varchar(191)         | YES  |     | NULL    | PERSISTENT     |
| title      | varchar(191)         | NO   |     | NULL    |                |
+------------+----------------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)

The storedAs-method does seem to be the right way as suggested in this Answer.

What am I doing wrong?



via Chebli Mohamed

Laravel 5 - Blob doesn't retrive an image right right

I'm using laravel to store an image (generated from a canvas) but when I retrieve the value from the column and I pass it to the "src" attribute of an block it doesn't load and into the browser console I see the error "Failed to load resource: net::ERR_INVALID_URL".

migration

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTblTaccuinoTable extends Migration
{
/**
 * Schema table name to migrate
 * @var string
 */
public $set_schema_table = 'tbl_taccuino';

/**
 * Run the migrations.
 * @table tbl_taccuino
 *
 * @return void
 */
public function up()
{
    if (Schema::hasTable($this->set_schema_table)) return;
    Schema::create($this->set_schema_table, function (Blueprint $table) {
        $table->engine = 'InnoDB';
        $table->increments('id_taccuino');
        $table->integer('id_paziente')->unsigned();
        $table->string('taccuino_descrizione', 45);
        $table->date('taccuino_data');
        $table->binary('taccuino_report_anteriore');
        $table->binary('taccuino_report_posteriore');

        $table->index(["id_paziente"], 'fk_tbl_taccuino_tbl_pazienti1_idx');


        $table->foreign('id_paziente', 'fk_tbl_taccuino_tbl_pazienti1_idx')
            ->references('id_paziente')->on('tbl_pazienti')
            ->onDelete('no action')
            ->onUpdate('no action');
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
 public function down()
 {
   Schema::dropIfExists($this->set_schema_table);
 }
}

Model

<?php

/**
* Created by Reliese Model.
* Date: Mon, 25 Dec 2017 12:47:05 +0000.
*/

namespace App\Models\Patient;

use Reliese\Database\Eloquent\Model as Eloquent;

/**
 * Class Taccuino
 * 
 * @property int $id_taccuino
 * @property int $id_paziente
 * @property string $taccuino_descrizione
 * @property \Carbon\Carbon $taccuino_data
 * @property boolean $taccuino_report_anteriore
 * @property boolean $taccuino_report_posteriore
 * 
 * @property \App\Models\Pazienti $tbl_pazienti
 *
 * @package App\Models
 */
class Taccuino extends Eloquent
{
protected $table = 'tbl_taccuino';
protected $primaryKey = 'id_taccuino';
public $incrementing = false;
public $timestamps = false;

protected $casts = [
    'id_taccuino' => 'int',
    'id_paziente' => 'int',
];

protected $dates = [
    'taccuino_data'
];

protected $fillable = [
    'id_paziente',
    'taccuino_descrizione',
    'taccuino_data',
    'taccuino_report_anteriore',
    'taccuino_report_posteriore'
];

public function tbl_pazienti()
{
    return $this->belongsTo(\App\Models\Patient\Pazienti::class, 'id_paziente');
}
}


Inside my blade view

<img id="canvas_dolore" class="M" src=""></img>

PS: The blob string value starts with "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA..."



via Chebli Mohamed

View Routes dynamic data array in laravel

In laravel Document View Route is defined with array of data

Route::view('/welcome', 'welcome', ['name' => 'Taylor']);

http://ift.tt/2EtcTMw

how can I pass value to it from a view



via Chebli Mohamed

how to claim a jwt token based on user->id in lumen

I installed lumen 5.5 and "tymon/jwt-auth": "^1.0@dev" as well.

I configured everything and also claiming token on email and password. I want to claim token based on user id and store claimed user in jwt_auth_guard. what will be best approach? please help me out.



via Chebli Mohamed

How to retireve data stored in select2 dropdown?

I am using laravel 5 and select2 dropdown for selecting various tags similar to stackoverflow tag field.

So once a number of tags are selected i want to retrieve them in the form of array and use it in laravel 5's controller to validate and store.

Also if user clicks edit post i want to add all the tags in the dropdown from the database so user can easily make changes.

1) So mainly i want to know how can i retrieve data in form of array from select2

2) populate the select2 with data when user clicks edit How do i achieve these 2 functionality ?

<select multiple="multiple"
    id="class_select"
    class="form-control"
    name="tag_select"
    value=""
    required
    >

    <option value="">PHP</option>
    <option value="">C++</option>
</select>

<script>
    $( document ).ready(function() {

        $("#tag_select").select2();

        $('#showbola').click(function(){
            $("#tag_select").text();
        });
    });
</script>



via Chebli Mohamed