Exemple #1
0
 /**
  * set Content Method
  */
 public function setContent($content)
 {
     if ($this->id) {
         $validator = Validator::make($content, Channel::findOrFail($this->channel_id)->fields);
         if ($validator->fails()) {
             throw new \InvalidArgumentException(head(array_flatten($validator->messages())));
         }
         $this->content = $content;
         return;
     }
     throw new \InvalidArgumentException("Primary Key Not Set.");
 }
 /**
  * Get the services provided by the provider.
  *
  * @return array
  */
 public function boot()
 {
     Channel::saved(function ($channel) {
         $channels = var_export(Channel::all()->toArray(), true);
         file_put_contents(config_path() . "/content-entry.php", "<?php return {$channels};");
     });
     Channel::deleted(function ($channel) {
         $channels = var_export(Channel::all()->toArray(), true);
         file_put_contents(config_path() . "/content-entry.php", "<?php return {$channels};");
     });
     Entry::saved(function ($entry) {
         $channel = Channel::findOrFail($entry->channel_id);
         event("{$channel->name}.saved");
     });
     Entry::deleted(function ($entry) {
         $channel = Channel::findOrFail($entry->channel_id);
         event("{$channel->name}.deleted");
     });
     $this->publishes([__DIR__ . '/../../../config/content-entry.php' => config_path('content-entry.php')]);
     $this->publishes([__DIR__ . "/../../..//migrations" => database_path('migrations')], 'migrations');
 }