title: Laravel's Trait proper usage inside Controller
body: <p>I am trying to make my code more readable and reusable along my app.
  I created for this purpose a Trait but I couldn't use it (probably I didn't understand the right way to import it).
  My code is as follows:</p>
  <p>Trait</p>
  <pre><code>    namespace App\Http\Traits;
  
  use App\Models\FlightManagement\Aircraft;
  use App\Models\FlightManagement\FunctionType;
  use App\Models\FlightManagement\LogEntry;
  use Illuminate\Support\Facades\Request;
  
  trait FlightTrait
  {
      public function store_new_flight(Request $request, $log_entry)
      {
          $log_entry-&gt;aircraft_id = $request-&gt;aircraft_id;
          $log_entry-&gt;adep_id = $request-&gt;adep;
          $log_entry-&gt;ades_id = $request-&gt;ades;
          $log_entry-&gt;date = date('Y-m-d', strtotime($request-&gt;date));
          $log_entry-&gt;atd = $request-&gt;atd;
          $log_entry-&gt;ata = $request-&gt;ata;
          $log_entry-&gt;operational_condition_id = $request-&gt;operational_condition_id;
          $log_entry-&gt;function_type_id = $request-&gt;function_type_id;
          $log_entry-&gt;instructor_id = $request-&gt;instructor_id;
          $log_entry-&gt;student_id = $request-&gt;student_id;
          $eet = date('H:i', (strtotime($request-&gt;ata)) - (strtotime($request-&gt;atd)));
          if ($request-&gt;ata &lt;= $request-&gt;atd) {
              return redirect()-&gt;back()-&gt;with('error', 'ATA can not be greater or equal to ATD');
          }
          $function_type_obj = FunctionType::find($request-&gt;function_type_id)-&gt;name;
          if ($function_type_obj == 'Dual Command' and $request-&gt;instructor_id == '') {
              return redirect()-&gt;back()-&gt;with('error', 'Instructor Must be on Board!!!');
          }
          if ($function_type_obj == 'Single Pilot') {
              $log_entry-&gt;solo_flight = 1;
          }
          $aircraft_obj = $request-&gt;aircraft_id;
          $aircraft_type_obj = Aircraft::find($aircraft_obj)-&gt;aircraft_type-&gt;name;
          if ($aircraft_type_obj == 'MEP') {
              $log_entry-&gt;mep_flight = 1;
          }
          if ($aircraft_type_obj == 'SIM') {
              $log_entry-&gt;sim_flight = 1;
          }
          $log_entry-&gt;eet = $eet;
          $log_entry-&gt;save();
          return $log_entry;
      }
  
  }
  </code></pre>
  <p>Basically my final goal is to use it inside a controller function as follows:</p>
  <p>Controller</p>
  <pre><code>use App\Http\Traits\FlightTrait;
  
  class LogEntryController extends Controller
  {
     
      use FlightTrait;
      public function store_new_flight(Request $request)
      {
          $log_entry = new LogEntry();
  
          $log_entry-&gt;$this-&gt;store_new_flight($request, $log_entry);
  
          return redirect()-&gt;route('flight.list')-&gt;with('success', 'Flight Added Successfully');
      }
  }
  </code></pre>
  <p>I know that the problem is likely to be in the way I call the trait function, but I googled around and I couldn't find anything.
  The error is giving me is:</p>
  <p>Error</p>
  <pre><code>Object of class App\Http\Controllers\FlightManagement\LogEntryController could not be converted to string
  </code></pre>