]> _ Git - psq.git/commitdiff
make orga searchable
authorLouis Jeckel <louis.jeckel@outlook.cm>
Sat, 29 Aug 2020 16:10:29 +0000 (18:10 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Sat, 29 Aug 2020 16:10:29 +0000 (18:10 +0200)
app/Nova/OrganizationType.php
app/Nova/User.php
app/Organization.php

index ef6826f403ddeb71c13cd8acab813b3051ad702e..91c8f23f2c39584185c4941644c555a4c2de156b 100644 (file)
@@ -52,7 +52,7 @@ class OrganizationType extends Resource
     public function fields(Request $request)
     {
         return [
-            ID::make()->sortable(),
+//            ID::make()->sortable(),
             Text::make('Nom', 'name'),
             Text::make('Raccourci', 'slug')->nullable(),
             HasMany::make('Organisations', 'organizations', Organization::class),
index 23d675a2da56a344d831ccfffd38d8c64462fc9b..031aea29ec38384cad44516debeef6c4adcc01b4 100644 (file)
@@ -57,6 +57,7 @@ class User extends Resource
     public function fields(Request $request)
     {
         return [
+            ID::make()->sortable(),
             Text::make('PrĂ©nom', 'first_name'),
             Text::make('Nom', 'last_name'),
             Text::make('Email'),
index 55fd1b26c3332d26e5862d001b94b4efdec30ac3..566ea485b022d1cd3e959b0a3fbaebe7f0f47178 100644 (file)
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\HasMany;
+use Laravel\Scout\Searchable;
 
 /**
  * Class Organization
@@ -15,6 +16,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
  */
 class Organization extends Model
 {
+
+    use Searchable;
+
     protected $casts = [
         'subscription_active' => 'boolean'
     ];
@@ -22,6 +26,13 @@ class Organization extends Model
     protected $guarded = [];
 
 
+    public function toSearchableArray()
+    {
+        return [
+            'name' => (string) $this
+        ];
+    }
+
     /**
      * @return boolean
      */
@@ -55,4 +66,12 @@ class Organization extends Model
         return $this->belongsTo(OrganizationType::class, 'type_id');
     }
 
+    /**
+     * @return string
+     */
+    public function __toString(): string
+    {
+        return $this->name;
+    }
+
 }